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
Anonymous
Not applicable

Help please! If then do statement in DAX

Hi,

 

I need help in coding this using DAX. I am getting circular dependency error. What I want is to make a DAX code similar to if then do statement in SAS.

 

Algorithm:

 

If 1<=range<=5 then do;

   if 0<discount<1 then A

   if 1<discount<2 then B

   if 2<discount<3 then C

end;

If 6<=range<=10 then do;

   if 4<discount<5 then A

   if 5<discount<6 then B

   if 6<discount<7 then C

end;

else then do;

   if 10<discount<11 then A

   if 11<discount<12 then B

   if 12<discount<13 then C

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try like

 

Switch( True(),
[range] <=5 , Switch(True() ,
[discount]<1, "A",
[discount]<2, "B",
[discount]<3, "C") ,
[range] <=10 , Switch(True() ,
[discount]<5, "A",
[discount]<6, "B",
[discount]<7, "C"),
Switch(True() ,
[discount]<11, "A",
[discount]<12, "B",
[discount]<13, "C") )

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , Try like

 

Switch( True(),
[range] <=5 , Switch(True() ,
[discount]<1, "A",
[discount]<2, "B",
[discount]<3, "C") ,
[range] <=10 , Switch(True() ,
[discount]<5, "A",
[discount]<6, "B",
[discount]<7, "C"),
Switch(True() ,
[discount]<11, "A",
[discount]<12, "B",
[discount]<13, "C") )

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.