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 / If Empty Expression wi...
Power Automate
Unanswered

If Empty Expression with Math Function

(0) ShareShare
ReportReport
Posted on by 41

Good day and thank you for your interest.

 

We have a business requirement where we want the use a power automate expression to check the value against a field from Get Rows ID. Basically if the field value is empty or it contains a data value, then we want to replace and update the field by ADDING the previously contained data value and another field value. Please let me know you need any further clarification?

 

Regards,

Sunny

 

PayPal Invoice Expression Test Flow.PNG

Categories:
I have the same question (0)
  • Rhiassuring Profile Picture
    8,690 Moderator on at

    "if the field value is empty or it contains a data value" - so, in any circumstance, you want to take the action? I feel like maybe a word was left out here, or it was mistyped - do you mean something more specific here?


  • arslanarif Profile Picture
    41 on at

    Thank you for your response. 

     

    Yeah I had a feeling that I may have been unclear. Let's try again with a brief background on the flow. The expression is supposed to check whether the field ('crbdd_invoicepaidamount') contains a data value or whether if the field value is empty. This field is on the invoice entity and we are looking to check when partial payments were previously submitted against the invoice:

     

    If yes, then there should be a data value in that field, which we would then want to add up and calculate with another field ('crbdd_PaymentAmount').

     

    If no, then the field should be empty and that's where we are getting expression error when trying to add it to the second field. Ideally, we want the expression to ignore if the field is empty, and calculate the addition with the second field as necessary. Any help would be appreciated.

     

    Regards,

     

    Invoice Expression error.PNG

  • Rhiassuring Profile Picture
    8,690 Moderator on at

    Ahhh, yes, that does help clarify. Thank you!

    I think you can get through this in a single compose - if(empty('crbdd_invoicepaidamount'),'other_field',add('crbdd_invoicepaidamount','other_field'))

    (If I'm understanding correctly.) 

    Writing that out would be ... "if the CRBDD field is empty, then just put in the Other Field's value; if it's got something in it, then add whatever's in it to the Other Field's value."

    Am I on the right track? 

  • arslanarif Profile Picture
    41 on at

    Hmm that makes perfect sense in theory; a bit of a correction, the 'other field' is actually a variable so the dynamic output is like this: variables('VarInvoiceAmount')

     

    So I applied the equation as you recommended, their is an additional required parameter in the expression that is missing at the end after 'other_field'. The tooltip prompt says. " 

    if(expression: boolean, valueIfTrue: any, valueIfFalse: any) which is a required. 

    The value to return if the expression is 'false'. Returns a specified value based on whether the expression resulted in true or false

     

    So currently, this is what I have: 

     

    if(empty('outputs('Get_a_row_by_ID')?['body/crbdd_invoicepaidamount']'),add(outputs('Get_a_row_by_ID')?['body/crbdd_invoicepaidamount'],variables('VarInvoiceAmount')), valueIfFalse: any)

     

    -What do you think valueIfFalse would be? I put '0' and that didn't work. Or maybe I should attempt a different equation together?

     

    Regards,

     

  • Verified answer
    Rhiassuring Profile Picture
    8,690 Moderator on at

    I was typing that formula from memory when I last responded and forgot some syntax, I think...

    One question though, are both of your values coming in as numbers or text? If they are numbers, will it show 0 if empty, or just be straight up empty? It looks like your CRBDD is coming in as text. So let's fix up the formula to account for that, I'll handle both as if text...

    if(empty(outputs('Get_item')?['body/crbdd_paidinvoiceamount']),variables('VarInvoiceAmount'),add(int(variables('VarInvoiceAmount')),int(outputs('Get_item')?['body/crbdd_paidinvoiceamount'])))
     
    outputs('Get_item')?['body/crbdd_paidinvoiceamount']

    in the above is outputs('Get_a_row_by_ID')?['body/crbdd_invoicepaidamount'] for you.

     

    Here's how it looks when it runs: 

     

    If CRBDD = 444 and VarInvoiceAmount is 555, the result is 999. 

    If CRBDD = empty and VarInvoiceAmount is 555, the result is 555.


    Let me know about the number situation, though.

     

     

     

     

     

  • arslanarif Profile Picture
    41 on at

    Beautiful! Works Perfectly. Thank you so much for your kind and generous help. God Bless!

     

    Regards,

    Sunny

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