Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Multiple condition in if

hello , please i need some help here what i have 
if ( ca = 0 ) in date1 and ca <>0 in date2 then 'new' 

else if ( ca in date1 < ca in date2 ) then 'up')

else if (ca in date 1 > ca in date then 'down')

else if ca <> 0  in date1 and ca = 0 in date 2 then 'unkhnown')

 

so i try to write it with dax like this    

if ( (ca=0 , date1 ), 'nouveaux' , if(ca <>0 , date2), 'nouveaux', if ((ca , date1 )<(ca , date2), 'croissance', if ((ca , date1 )>(ca , date2), 'perte',if((ca<>0 , date1 ), (ca =0 , date2),'null'))))) 

or 

if ( (ca=0 , date1 ) && (ca <>0 , date2); 'nouveaux';  if ((ca , date1 )<(ca , date2); 'croissance'; if ((ca , date1 )>(ca , date2) ; 'perte' ; if((ca<>0 , date1 )&&(ca =0 , date2);'null')))))


I have a problem to acces to power BI so until i found a solution i want to be sure that my dax querry is right .
Any suggestion please 
thank you 

  • Hello, Switch should be perfect.

     

    I assume two measures,

    CA1 for ca in date1 and CA2 for ca in date2.

     

    Switch(
    TRUE(),
    [CA1]=0 && [CA2]<>0, 'new', --condition 1
    [CA1]>[CA2], 'up', --condition 2
    [CA1]<[CA2], 'down' --condition 3
    [CA1]<>0 && [CA2]=0, 'unknown' --condition 4
    BLANK()) --else

    For further information check this article.

     

    I hope this helps. I want miss the SWITCH function anymore.

14 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      i have problem to access to my data but 'CA' it's a measure ; an amount and date1 is a date from Dimension date that's why i called date1 because i have with 2 date that's why 

  • Hello, Switch should be perfect.

     

    I assume two measures,

    CA1 for ca in date1 and CA2 for ca in date2.

     

    Switch(
    TRUE(),
    [CA1]=0 && [CA2]<>0, 'new', --condition 1
    [CA1]>[CA2], 'up', --condition 2
    [CA1]<[CA2], 'down' --condition 3
    [CA1]<>0 && [CA2]=0, 'unknown' --condition 4
    BLANK()) --else

    For further information check this article.

     

    I hope this helps. I want miss the SWITCH function anymore.

    • Anonymous's avatar
      Anonymous
      Not applicable

      thank you it work but i have juste a little problem i want to regroup my data by  criterion . so i want to have those criterion in line and CA1 and CA2 in column ; the problem that power consider it as a measure so it automatically put it in colunm what ken i do please

      • Floriankx's avatar
        Floriankx
        Solution Sage

        Hello,

         

        try to create a calculated column with this formula.