Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
manuelfigueira
Helper II
Helper II

IF conditional with several conditions (Values)

Hello,

 

I've been trying to create a IF conditional DAX where happen the below:

 

if X value is between 0 - 30 show me "0 - 30", 

if X value is between 31 - 60 show me "31-60",

If X value is between 61 - 90 show me "61 - 90",

if X value is between 91 - 120 show me 91 - 120"

 

Any takers? 🙂

 

Thanks a lot!!

 

2 ACCEPTED SOLUTIONS

Hi,

@manuelfigueira 

Switch is used to combine multiple IFs in one neat formula:

Column = SWITCH(TRUE(),

        [Value]>= 0 && [Value]<=30,"0-30",

        [Value]>=31 && [Value]<=60,"31-60",

        [Value]>=61 && [Value]<=90,"61-90",

        [Value]>=91 && [Value]<=120,"91-120"

)  


Paul
Best

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly, Kudos is nice too.

 

View solution in original post

@manuelfigueira ,

 

I thought earlier your Column X is Text value. If it is Numeric or whole value so make little changes in earlier posted Calculated Column:

Calculated Column = SWITCH(Table1[Column X],

                                 AND([Column X]>=0,[Column X]<30),"0-30",

                                AND([Column X]>=31,[Column X]<60),"31-60",

                                 AND([Column X]>=61,[Column X]<90),"61-90",

                                 AND([Column X]>=91,[Column X]<120),"91-120")

 

Don't forget to hit Thumbs up and accept this as a solution if you find it helpful! 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

4 REPLIES 4
Tahreem24
Super User
Super User

Create a calculated column using switch like below :

Column=SWITCH(Table[Column X], "0-30","0-30","31-60","31-60","61-90","61-90","91-120","91-120")

Please give Kudos and accept this as a solution if it helps you.
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

@manuelfigueira ,

 

I thought earlier your Column X is Text value. If it is Numeric or whole value so make little changes in earlier posted Calculated Column:

Calculated Column = SWITCH(Table1[Column X],

                                 AND([Column X]>=0,[Column X]<30),"0-30",

                                AND([Column X]>=31,[Column X]<60),"31-60",

                                 AND([Column X]>=61,[Column X]<90),"61-90",

                                 AND([Column X]>=91,[Column X]<120),"91-120")

 

Don't forget to hit Thumbs up and accept this as a solution if you find it helpful! 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Hi Tahreem,

 

Thank you for your answer! I tried it but it says this "Function 'SWITCH' does not support comparing values of type Integer with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values."

 

I was thinking if is possible using something like Formula = If([Age] => 0 but < 30, "0-30"........ and so on! 

 

Do you thik that's possible?

 

Thanks a lot!!

Hi,

@manuelfigueira 

Switch is used to combine multiple IFs in one neat formula:

Column = SWITCH(TRUE(),

        [Value]>= 0 && [Value]<=30,"0-30",

        [Value]>=31 && [Value]<=60,"31-60",

        [Value]>=61 && [Value]<=90,"61-90",

        [Value]>=91 && [Value]<=120,"91-120"

)  


Paul
Best

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly, Kudos is nice too.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.