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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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