cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

IF Function with 3 or more posible results HELP!

This could be basic Dear Community but I need to find the way to clasify a result in 3 posibilities using "If"

 

I need to know if a x number es between 9, 16, 24.

 

ANY HELP WOULD BE SO MUCH APPRECIATED

 

My try was the following:

 

Rango* = IF('column (Chil'[TotalhoursDiff**]<= 'column (Chil'[Rango 1],"1",IF(AND('column (Chil'[TotalhoursDiff**]<='column (Chil'[Rango 2],'column (Chil'[TotalhoursDiff**]<='column (Chil'[Rango 3]),"2","3"))

 

Captura5.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: IF Function with 3 or more posible results HELP!

Hmm, that's odd, do you have <= in the formula for the second condition?

 

The general format of the IF is:

 

IF(<condition>, <if true>, <if false>)

 

So, you just keep tacking on IF statements in the <if false> area. So, if you need a fourth value, you would just tack on an IF statement where you have the 3. You can string these together indefinitely but you might want to take a look at the SWITCH statement instead of the IF statement as it will be cleaner code-wise.


I have book! Learn Power BI from Packt


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

9 REPLIES 9
Super User
Super User

Re: IF Function with 3 or more posible results HELP!

You have a mystery AND in there, not sure why. Try this:

 

Rango* = IF('column (Chil'[TotalhoursDiff**]<= 'column (Chil'[Rango 1],"1",IF('column (Chil'[TotalhoursDiff**]<='column (Chil'[Rango 2],2,3))

I have book! Learn Power BI from Packt


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

jthomson New Contributor
New Contributor

Re: IF Function with 3 or more posible results HELP!

What range of TotalhoursDiff** should produce an output of 1, 2 or 3 respectively?

Re: IF Function with 3 or more posible results HELP!

Exactly...and I might need a 4° range!

 

Thank @jthomson

Re: IF Function with 3 or more posible results HELP!

Hi @Greg_Deckler thats work better thank you but I have 2 last questions... what can I do when is 16:00 to keep it in range 2... because when is 16:00 goes to range 3.

 

What About if I need to add a fourth range (4)... How do I continue with the formula?

 

That would be all...hopefully you can give me a hand!!!

 

Captura.JPGWRONG!!

Super User
Super User

Re: IF Function with 3 or more posible results HELP!

Hmm, that's odd, do you have <= in the formula for the second condition?

 

The general format of the IF is:

 

IF(<condition>, <if true>, <if false>)

 

So, you just keep tacking on IF statements in the <if false> area. So, if you need a fourth value, you would just tack on an IF statement where you have the 3. You can string these together indefinitely but you might want to take a look at the SWITCH statement instead of the IF statement as it will be cleaner code-wise.


I have book! Learn Power BI from Packt


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

jthomson New Contributor
New Contributor

Re: IF Function with 3 or more posible results HELP!

Would SWITCH actually work if it's trying to compare a range of values? AFAIK it would only work with constant values, and OP's got a lot of potential constant values

Re: IF Function with 3 or more posible results HELP!

Pretty decent advices fellows!!!! thank you so much

Super User
Super User

Re: IF Function with 3 or more posible results HELP!

Sure you could use SWITCH

 

https://community.powerbi.com/t5/Desktop/Switch-amp-Calculate-Issue/m-p/352890#M158765


I have book! Learn Power BI from Packt


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

jthomson New Contributor
New Contributor

Re: IF Function with 3 or more posible results HELP!

Heh, didn't think of using a variable as an intermediate step, that's nice

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 39 members 1,608 guests
Please welcome our newest community members: