Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

IF DAX formula for multiple conditions

Hello,

 

I have created a calculated column using the CALCULATEX function. Based on this column, i want to group the values into 4 different groups:

<0

>0 & <5

>5 & <10

>10

 

I have tried the following formula but get an error notice saying that syntax for ',' is incorrect.

 

new2 = IF('datauserprofile (2)'[Column]<0),"<0", BLANK()),
IF(AND('datauserprofile (2)'[Column]>0, 'datauserprofile (2)'[Column]<5),">0 & <5",
  IF(AND('datauserprofile (2)'[Column]>5, 'datauserprofile (2)'[Column]<10),">5 & <10",
    IF('datauserprofile (2)'[Column]>10,">10", BLANK())
 
Is there any other way to achieve the particular grouping i am looking for? I understand that I could create a conditional column in the query editor but since I am using DAX formula to come up with the column that I am basing the information on, that would not be possible.
 
Thank you.
 
Best regards,
vvmob
 
  • Anonymous 

    Try this calculated column formula

     

     
    Profile = 
    SWITCH(
        TRUE(),
        Data[Column]<0, "<0",
        Data[Column]<=5, "0 to 5",
        Data[Column]<=10, "6 to 10",
        BLANK()
    ) 

     

    Hope this helps

     

2 Replies

  • ChandeepChhabra's avatar
    ChandeepChhabra
    Icon for Impactful Individual rankImpactful Individual

    Anonymous 

    Try this calculated column formula

     

     
    Profile = 
    SWITCH(
        TRUE(),
        Data[Column]<0, "<0",
        Data[Column]<=5, "0 to 5",
        Data[Column]<=10, "6 to 10",
        BLANK()
    ) 

     

    Hope this helps

     
  • Hi,

    Try this calculated column formula

    =IF('datauserprofile (2)'[Column]>10,">10",IF('datauserprofile (2)'[Column]>5,">5",IF('datauserprofile (2)'[Column]>0,">0", "<0")))

    Hope this helps.