cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mezcalbean
Helper II
Helper II

If statement with values summarise from 4 choices

H I have a text field that is calculating a few fields charttxt.Text - I want with another field tell with in a range or to summarise from 4 choices depending on the number resulted

 

With({input:Value(charttxt.Text)},
     If(input >= 3, "Low",
        input >= 4, "Intermediate",
        input >= 9, "High",
        input >= 15, "Very High",
        
        "1"
     )
)

 I am only getting low or for example 1 when no score?

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
zmansuri
Super User
Super User

Your conditions are wrong. Your first condition is >3 Your second is >4.

Now let's say the input is 5. Then it satisfies the 1st condition because 5 is greater than 3. That's why you always get Low. Try this code instead. 

 

With(
{input: Value(charttxt.Text)},
If(
input >= 3 && input < 4,
"Low",
input >= 4 && input < 9,
"Intermediate",
input >= 9 && input < 15,
"High",
input >= 15,
"Very High",
"1"
)
)

View solution in original post

4 REPLIES 4
Abhilash_Swain
Super User
Super User

Hi @mezcalbean ,

Could you please try with 'Switch" instead 

zmansuri
Super User
Super User

Your conditions are wrong. Your first condition is >3 Your second is >4.

Now let's say the input is 5. Then it satisfies the 1st condition because 5 is greater than 3. That's why you always get Low. Try this code instead. 

 

With(
{input: Value(charttxt.Text)},
If(
input >= 3 && input < 4,
"Low",
input >= 4 && input < 9,
"Intermediate",
input >= 9 && input < 15,
"High",
input >= 15,
"Very High",
"1"
)
)

Thank you @Abhilash_Swain I will try and learn Switch - I have only just come across this 

Thank you @zmansuri that worked as I wanted, I was unsure how to put a between in. 

 

Thank you

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (2,198)