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
vmsouza30
Helper I
Helper I

IF Function - 4 Conditions,

Hi,

 

I need to establish the value of 5 conditions, how to do using DAX?

 

Exemple:

 

Group 1 = "18-27",

Group 2 = "28-35",

Group3 = "36-43",

Group 4 = "44-50",

Group 5 = "50+"

 

I make this formula but is incorrect: 

 

Age Group = IF(AND([Age]>17 [Age]<28),"18-27",

IF(AND([Age]>27, [Age]<36),"28-35",

IF(AND([Age]>35, [Age]<44),"36-43"

IF(AND([Age]>43, [Age]<51),"44-50",

IF([Age]>50,"50+", BLANK())

))))

 

I Can Help?

1 ACCEPTED SOLUTION
vanessafvg
Super User
Super User

look at using the switch statement with true

 

here is the whole article  

 

https://powerpivotpro.com/2012/06/dax-making-the-case-for-switch/

 

 

example taken from above but this is the one you would need to use)

 

SWITCH(TRUE(),
             AND([Fund Balance]>=0, [Fund Balance]<=10000), “Up to $10,000”,
             AND([Fund Balance]>=10001, [Fund Balance]<=50000), “$10,001 to 50,000”,
             AND([Fund Balance]>=50001, [Fund Balance]<=100000), “$50,001 to 100,000”,
             AND([Fund Balance]>=100001, [Fund Balance]<=500000), “$100,001 to 500,000”,
             AND([Fund Balance]>=1500001, [Fund Balance]<=1000000), “$500,001 to 1,000,000”,
             “greater than $1,000,000”
           )





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




View solution in original post

1 REPLY 1
vanessafvg
Super User
Super User

look at using the switch statement with true

 

here is the whole article  

 

https://powerpivotpro.com/2012/06/dax-making-the-case-for-switch/

 

 

example taken from above but this is the one you would need to use)

 

SWITCH(TRUE(),
             AND([Fund Balance]>=0, [Fund Balance]<=10000), “Up to $10,000”,
             AND([Fund Balance]>=10001, [Fund Balance]<=50000), “$10,001 to 50,000”,
             AND([Fund Balance]>=50001, [Fund Balance]<=100000), “$50,001 to 100,000”,
             AND([Fund Balance]>=100001, [Fund Balance]<=500000), “$100,001 to 500,000”,
             AND([Fund Balance]>=1500001, [Fund Balance]<=1000000), “$500,001 to 1,000,000”,
             “greater than $1,000,000”
           )





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




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.