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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Getting Null/Empty Val...
Power Automate
Unanswered

Getting Null/Empty Values to Produce a Value of 0 so the flow Doesn't Fail

(0) ShareShare
ReportReport
Posted on by 78

Hello, I need some help. I currently have flow that when an item is created or modified from the Project Budget Hours List it is than converted into the Jobs Budget Hours List. The issue I am having is any time a user leaves a field blank in the form/list the flow will fail because of a null value. The low works perfectly if all the field are filled but not every time will every field be filled. I was wondering if somebody can help me with producing a value of 0 when a field is empty/null. My flow is Located below:

diegothompson12_0-1687877519393.pngdiegothompson12_1-1687877546219.png

diegothompson12_3-1687877623373.png

 

I would appreciate any help thanks!

Categories:
I have the same question (0)
  • wskinnermctc Profile Picture
    6,519 Moderator on at

    Use the expression if() combined with empty() to check the value.

     

    It will be something like if(empty([value]),0,[value]) so this expression says If the [value] is empty, then return zero 0, if not then return [value].

     

    A better example for the create item might be something like:

    if(empty(triggerOutputs()?['body/AdminDSG']),0,triggerOutputs()?['body/AdminDSG'])

     

    Just use your values in the expression. Let me know if this works for you,

     

  • diegothompson12 Profile Picture
    78 on at

    Hello @wskinnermctc,

     

    Thanks for the help. It kinda of works but puts in a zero no matter if there is a vale or not!

  • wskinnermctc Profile Picture
    6,519 Moderator on at

    You said you wanted it to show a zero 0 if they left the field blank.

     

    Did you want a different output?

  • diegothompson12 Profile Picture
    78 on at

    Hey @wskinnermctc 

     

    That is correct. I want the field to be 0 if it is left blank but it is still making it zero even if there is a number in that field. 

     

    Put the expression under the design DSG field to test it out:

    Formula: 

    if(empty(triggerOutputs()?['body/Design_DSG_HRS']),0,triggerOutputs()?['body/Design_DSG_HRS'])

    diegothompson12_1-1687886843225.png

    Project Budget Hours: 

    diegothompson12_2-1687886974820.png

    What is created on the Jobs Budget Hours List:

    diegothompson12_3-1687887041985.png

    I could be doing something wrong.

     

     

  • wskinnermctc Profile Picture
    6,519 Moderator on at

    I think it has to do with the sharepoint column name for your list Project Hours Budget and the column that has the display name "Design_DSG HRS" in your screenshot.

     

    Can you go to the column settings in your list and check the internal name of the column? You can see it up in the address bar.

    SharePoint Column Internal NameSharePoint Column Internal Name

     

    You can also check the value in the flow by hovering over the dynamic content.

    SharePoint Column Name Dynamic ContentSharePoint Column Name Dynamic Content

     

    So for my example column the expression would be:

    if(empty(triggerOutputs()?['body/Design_DSGHRS']),0,triggerOutputs()?['body/Design_DSGHRS'])

     

    Even though the display name is "Design_DSG HRS" the internal name is "Design_DSGHRS" so the internal name needs to be used in expressions.

  • diegothompson12 Profile Picture
    78 on at

    Hi @wskinnermctc 

     

    Here is the error message I am getting:

    diegothompson12_1-1687893821247.png

    The formula I used: 

    if(empty(triggerOutputs()?['body/Design_DSG']),0,triggerOutputs()?['body/Design_DSG'])
    The coulmn I am Trying to use:
    diegothompson12_2-1687893945186.png

     

     

  • Verified answer
    wskinnermctc Profile Picture
    6,519 Moderator on at

    Ok got it, this should work all of the time.

     

    We are using the coalesce() expression which gets the first non-null value from a line of items. So coalesce("Dan","Steve","Mark") would return "Dan". If you have coalesce(null,"Steve","Mark"), then it would return "Steve" since it skips over the first null item.

    I am also wrapping a zero 0 in the int() integer expression just to be sure it returns a number. 

     

     

    coalesce(triggerOutputs()?['body/Design_DSG'],int(0))

     

     

    Here is a screenshot of the expression

    Coalesce ExpressionCoalesce Expression

     

    This is basically saying if your value is null then return a zero 0 as an integer which just means number.

     

    Let me know how this works,

  • diegothompson12 Profile Picture
    78 on at

    @wskinnermctc  Thanks this works perfectly. This helped me understand a lot more about this application. 

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard