cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
erkindunya
Frequent Visitor

Need compare 20 fields on lable to get the outcome

We have 20 fields these are mix-match of radio button and dropdown(including multi-select) I use if to calculated result and store them in separate 20 label, and the result is these 4 strings: Low, Medium, High and Critical

12345678910
LowMediumHighCriticalMediumLowCriticalHighHighCritical
11121314151617181920
MediumLowCriticalLowHighCriticalMediumLowHighLow

 

The outcome will be the highest value available or presented on the above table which is Critical, even if we have 19 Low and 1 Critical it makes it to Critical.

 

Many thanks for your help in Advance

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
BrianS
Super User
Super User

The actual syntax will change slightly depending on the control, but say for a radio button,

In the OnChange of each control put:

If(var_FinalState<Radio.Selected.Value, Set(vaf_FinalState, Radio.Selected.Value))

That will set var_FinalState to the larger of it's previous state or the radio button, whichever is larger

Put that formula - or a similar one, depending on the control - in each OnChange event. Then no matter what order they change the controls var_FinalState will always have the greatest value.

For your final value a statement like 

Switch( var_FinalState,

      1, "Medium",

      2, "High",

      3, "Critical")

Will get your text value for your final output

   

View solution in original post

3 REPLIES 3
BrianS
Super User
Super User

I would make the Medium, High and Critical variables that you assign numbers to - 1,2 and 3.  Create a variable to hold the outcome - say var_FinalState, nad set the initial value to 1. Then each time a radio button or dropdown is changed you can compare the value that the control was just set to to the value of var_FinalState and set the new value to the greater of Var_FinalState or the control. That way it will always have the greatest value of any control. When all controls are adjusted yo will have the value you need.

Thanks Brian, I thout about that, how do I compare the 20 variables?

BrianS
Super User
Super User

The actual syntax will change slightly depending on the control, but say for a radio button,

In the OnChange of each control put:

If(var_FinalState<Radio.Selected.Value, Set(vaf_FinalState, Radio.Selected.Value))

That will set var_FinalState to the larger of it's previous state or the radio button, whichever is larger

Put that formula - or a similar one, depending on the control - in each OnChange event. Then no matter what order they change the controls var_FinalState will always have the greatest value.

For your final value a statement like 

Switch( var_FinalState,

      1, "Medium",

      2, "High",

      3, "Critical")

Will get your text value for your final output

   

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,008)