web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / SharePoint calculated ...
Power Automate
Answered

SharePoint calculated Column Value couldn't be formatted using Format Number

(3) ShareShare
ReportReport
Posted on by 18
I'm having an Calculated Colum "ExpiringIn" in SharePoint list which return values as Numbers with 0 decimals. When I'm trying to pass this value on an email content, it's becoming 2.00000000000000, instead of just the integer value.  To format this number, I have used the expression on the flow as "formatNumber(item()?['ExpiringIn'],'D2')".
 
Still getting error as the value is null.
 
Categories:
I have the same question (0)
  • Suggested answer
    Vish WR Profile Picture
    2,346 on at
     

    First, the column name ExpiresIn in item()?['ExpiresIn'] may not match the actual internal name SharePoint uses. Check the real internal name from List Settings and update it.

    The format string 'D2' does not work on decimal values and SharePoint calculated columns always return floats regardless of your decimal setting. Switch to '0' instead.

    formatNumber(coalesce(item()?['ExpiresIn'], 0), '0')

    The coalesce handles the null, and '0' strips the decimals cleanly.
     
    Vishnu WR
     
    Please  Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like 
  • Expiscornovus Profile Picture
    33,874 Most Valuable Professional on at

    Have you double checked that you used the correct internal field name?

    In the screenshot of your interface the name is Expiring In (not Expires In). Unless the internal name of the field is different?
     
    Otherwise try:
    item()?['ExpiringIn']
     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, LinkedIn, Bluesky profile or Youtube Channel
  • CU28041150-1 Profile Picture
    4 on at
    Can try the Formula change : 
    formatNumber(int(item()?['ExpiresIn']), 'D2')
  • Suggested answer
    Valantis Profile Picture
    4,902 on at
     
    The error is happening because some rows have a null value in ExpiresIn — you can see in your data that the second row has no License Number, which means the calculated column has nothing to calculate and returns null. formatNumber crashes on null.
    Wrap it in a coalesce to handle the null:
    formatNumber(coalesce(item()?['ExpiresIn'], 0), 'D2')
    This substitutes 0 when the value is null so the flow doesn't fail. Change the 0 to whatever default makes sense for your scenario.
    Also worth noting: 'D2' formats as a 2-digit integer with leading zero (e.g. 02, 59). If you just want a plain integer with no leading zero, use '0' instead:
    formatNumber(coalesce(item()?['ExpiresIn'], 0), '0')
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

  • Suggested answer
    11manish Profile Picture
    2,151 on at
    The issue occurs because SharePoint calculated columns return values as strings, not numbers, and sometimes return null if not yet evaluated.
     
    The formatNumber function fails because it expects a numeric value and does not support the 'D2' format.
     
    The correct approach is to first handle null using coalesce(), convert the value to a number using float(), and then format it. For example:
     
    formatNumber(float(coalesce(item()?['ExpiresIn'], 0)), '0') will return a clean integer without decimals.
  • Suggested answer
    Haque Profile Picture
    2,567 on at
    Hi @SO-06011624-0,
     
    The error and formatting issue you’re encountering happens because the value passed to formatNumber() is sometimes null, and also because the 'D2' format specifier expects an integer but your value might be null or decimal.

     

    How to fix this:

     
    1. Handle null values before formatting: Use a conditional expression to check if the value is null and provide a default (like 0) before formatting.
    2. Use the correct format specifier: 'D2' is for integers with at least 2 digits (e.g., 02, 15). If you want to format as a number with decimals, use 'N0' for no decimals or 'F0' for fixed-point with zero decimals.
     
     
    This expression will help:
    formatNumber(coalesce(item()?['ExpiresIn'], 0), 'N0')
    
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
  • SO-06011624-0 Profile Picture
    18 on at
    I have reconfirmed the internal name of the calcu;ated column - "ExpiringIn"..
     
    Also tried implementing the last 3 answers with no luck. Please find the attached error screenshot .
     
     
  • Suggested answer
    Haque Profile Picture
    2,567 on at
    Hi @SO-06011624-0,
     
    Let's narrow down, can you please see what the output of this expression coalesce(item()?['ExpiringIn'], 0)? Request you to pose the output of this expression.
     
    If you still get the error, it might be because the value is missing or the path item()?['ExpiresIn'] is incorrect in your flow context. Double-check that the dynamic content is correctly referenced.
     
    By the way - is the flow context the value is coming from the body() of a previous action rather than from the current item() in an iteration? If so, can you please try: coalesce(body()?['ExpiringIn'], 0)
     
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
  • SO-06011624-0 Profile Picture
    18 on at
    Tried this  coalesce(item()?['ExpiringIn'], 0) and getting this same error.
  • Verified answer
    Haque Profile Picture
    2,567 on at
    Hi @SO-06011624-0,
     
    I understand its giving you a real trouble!
     
    Just to narrow down and for a trial-check could you please check how these expressions behave?
    formatNumber(int(coalesce(item()?['ExpiringIn'], 0)), 'D2')
    
    Or
    formatNumber(float(coalesce(item()?['ExpiringIn'], 0)), 'N2')
     
     
    Would be glad if you please post me two resutls. Please let me know how these two expression behaves.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 889

#2
Valantis Profile Picture

Valantis 830

#3
Haque Profile Picture

Haque 505

Last 30 days Overall leaderboard