Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Need Help on My Dax

Hi

 

I need another line for my DAX to cover Cost = 0, Revenue >0 and Comment: Sales But No Cost

 

I'm having a hard time adding the above condition to the DAX I created below.

 

//NT

 

Comment =
SWITCH (
TRUE (),
'table[Variance] = 0.01, "No Revenue",
'table'[Variance] < 0 && table[Revenue] = 0, "Negative Variance with No Sales",
'table'[Variance] < 0, "Negative Variance"
)

 

 

  • Irwan's avatar
    Irwan
    2 years ago

    Anonymous 

     

    it should be like this, but i am not sure if this works since the previous DAX is not working as you said.

    Column = 

    SWITCH(
    TRUE(),

    'table'[Variance]='table'[Revenue],"Sales But No Cost"
    )

     

    Otherwise please provide you sample data/table or pbix (remove confidential information).

     

    Thank you.

6 Replies

  • hello Anonymous 

     

    if you have an error because of format error, that because the value in 'Cost' is blank, not 0

    change 0 to BLANK() should do.

     

    Hope this will help you.

    Thank you.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi,

       

      It still doesn't work. I guess because the cost data came from a different table...

       

       

      • Irwan's avatar
        Irwan
        Icon for Super User rankSuper User

        hello Anonymous 

         

        the conditional if looks like only calculate those values (Revenue, Cost, and Variance), so the source dont affect much as long as you have value in those column.

         

        Otherwise, if you dont mind, please provide your sample data in pbix (remove the confidential information) so we can work it out.

         

        Thank you.