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 / Multi Criterial to def...
Power Automate
Answered

Multi Criterial to define value

(0) ShareShare
ReportReport
Posted on by 27

I am creating a program for calculate labour charge. I created a Microsoft power form to collect 3 value. 

- No. of Normal working hour ($100)

- No. of OT  working hour ($200)

- No. of Overnight working hour ($300)

 

I have use "initialize variable" create value collect no. of working hour and int the value for calculation.

Before multiple hourly charge and email the result out, we need to verify number of working hours as below criterial. 

If value less than or equal to 0, value =0

If value larger than 0 and less than 2, value =2

If value larger than 2, value = value.

Which action should I use ? 

I found I am not able to use 2 or 3 if value in one compose. 

 

Please help to advise. Thanks!

 

iMac

 

 

  

 

Categories:
I have the same question (0)
  • v-chengfen-msft Profile Picture
    on at

    Hi @iMacPromoter ,

    Please try:

    if(lessOrEquals(variables('no.of working hour'),0),0,if(and(greater(variables('no.of working hour'),0),less(variables('no.of working hour'),2)),'2',if(greater(variables('no.of working hour'),2),variables('no.of working hour'))))

    I made a template for your reference

    vchengfenmsft_1-1678685263624.png

     

    vchengfenmsft_3-1678685312518.png

    Here is result:

    vchengfenmsft_0-1678685172059.png

    vchengfenmsft_2-1678685276598.png

     

     

    Best Regards

    Cheng Feng

  • Verified answer
    iMacPromoter Profile Picture
    27 on at

    Thank you very much for your reply. However, I found error as below. Could you please help on that? Thanks!

    iMacPromoter_0-1678693660843.png

    The formula = 

    if(lessOrEquals(variables('TotalNormalHour'),0),0,if(and(greater(variables('TotalNormalHour'),0),less(variables('TotalNormalHour'),2)),2,if(greater(variables('TotalNormalHour'),2),variables('TotalNormalHour'))))
     
    Error message:
    iMacPromoter_1-1678693846666.png

     

    iMac

     

     

  • Verified answer
    v-chengfen-msft Profile Picture
    on at

    Hi @iMacPromoter ï¼Œ

    Sorry, the formula I gave did not take into account the case of equal to 2, so the formula failed.

    Please try :

    if(lessOrEquals(variables('TotalNormalHour'),0),0,if(and(greater(variables('TotalNormalHour'),0),lessOrEquals(variables('TotalNormalHour'),2)),2,if(greater(variables('TotalNormalHour'),2),variables('TotalNormalHour'))))

     

     

    Best Regards

    Cheng Feng

  • iMacPromoter Profile Picture
    27 on at

    I found the formula is still not works and I found the flow will pass on value =0 or below 2. If value over 2 than error will shown. But if value over 0 and below 2, the value will not auto adjust to 2. Could you please advise? Thansk!

     

    iMacPromoter_0-1678701527044.png

     

    iMac

  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    I would suggest making a few changes to your Microsoft Form as described below. For all of your Working Hours fields do the following.

    • Restrict the entry for all the hours to number greater than or equal to 0.
    • Make the fields required.
    • Add subtitle informing the user to enter 0 if no hours.

    This will ensure the data you get in your flow is never empty and a number greater than or equal to 0.

    grantjenkins_0-1678712608301.png

     

    Clicking on Submit with no value entered.

    grantjenkins_1-1678712679596.png

     

    Entering a number less than 0

    grantjenkins_2-1678712699004.png

     

    Entering a non-number

    grantjenkins_3-1678712769639.png

     

    Then within your flow use the following expressions.

    //Initialize variable - change to your actual Microsoft Form field
    float(outputs('Get_response_details')?['body/r36af96f52ccb46ea8a572a44cc9094c0'])
    
    //Compose
    if(
     and(
     greater(variables('numberOfNormalWorkingHours'), 0),
     lessOrEquals(variables('numberOfNormalWorkingHours'), 2)
     ),
     2,
     if(
     greater(variables('numberOfNormalWorkingHours'), 2),
     variables('numberOfNormalWorkingHours'),
     0
     )
    )

     

    grantjenkins_4-1678712865101.png


    ----------------------------------------------------------------------
    If I've answered your question, please mark the post as Solved.
    If you like my response, please consider giving it a Thumbs Up.

  • Chriddle Profile Picture
    8,441 Super User 2025 Season 2 on at

    You only need 2 comparisons and coalesce() handles null value:

    if(
    	greater(coalesce(outputs('No'), 0), 2),
    	outputs('No'),
    	if(
    		greater(coalesce(outputs('No'), 0), 0),
    		2,
    		0
    	)
    )

     

  • iMacPromoter Profile Picture
    27 on at

    Hello,

     

            Thank you very much for your reply. I have changed the form and code in the float. I found compose parts is works. But when I paste it in email and calculate (* hourly charge). I found the value is still keep before compose. (e.g. input value =1, in compose action =2, in email =1.) I have tried to add apply to each but show below error message. Please help! Thanks!

    iMacPromoter_1-1678759733811.png

    iMacPromoter_2-1678760559636.png

    iMacPromoter_3-1678760652823.png

     

    iMac

  • Verified answer
    Chriddle Profile Picture
    8,441 Super User 2025 Season 2 on at

    You do the calculation in the compose action, but in the mail you still use the variable.

  • iMacPromoter Profile Picture
    27 on at

    Dear all,

     

             Thank you very much for your support.  Finally I successfully create my first flow for my company. I would like to ask more on the IF script. Could you please help to advise? Thanks!

    If(and(greater(variables('TotalNormalHour'),0),lessOrEquals(variables('TotalNormalHour'),2)),2,If(greater(variables('TotalNormalHour'),2),variables('TotalNormalHour'),0))

    1. For If statement, can we use more than 1 If statement in one compose action (or any limit on If statement in one compose)

    2. What is the function of and in this formula? How should I use? 

     

    iMac

  • v-chengfen-msft Profile Picture
    on at

    Hi @iMacPromoter ,

    Sorry, it took so long to reply to you,

    the link below is the formula document link about power automate, please check

    Reference guide for expression functions - Azure Logic Apps | Microsoft Learn

     

     

    Hope this helps you

     

    Best Regards

    Cheng Feng

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 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard