Forum Discussion

Avivek's avatar
Avivek
Icon for Post Partisan rankPost Partisan
4 years ago
Solved

Need help with the dax

I need help with a dax, the dax at present is 

YOY Sales Growth details % = if([To Year Sales]>0,DIVIDE([To Year Sales]-[Sales Amount],[Sales Amount])*100)

 

If, from YTD is blank % should show as +100 and if To YTD is blank then it should show as %  column should show as -100. Can someone please help me with this dax
  • Avivek 

    IF(isblank(from Ytd),"100"%, if(isblank(to ytd),"-100",DIVIDE([To Year Sales]-[Sales Amount],[Sales Amount])*100)
    Try this!

     

3 Replies

  • VijayP's avatar
    VijayP
    Icon for Community Champion rankCommunity Champion

    Avivek 

    IF(isblank(from Ytd),"100"%, if(isblank(to ytd),"-100",DIVIDE([To Year Sales]-[Sales Amount],[Sales Amount])*100)
    Try this!

     

    • Avivek's avatar
      Avivek
      Icon for Post Partisan rankPost Partisan

      Wow, VijayP , thankyou, i was tryig similar measure but now I can see what was the mistake i made. Thankyou for your help.

  • Avivek Try this:

    YOY Sales Growth details % =
    Var result_ = if([To Year Sales]>0,DIVIDE([To Year Sales]-[Sales Amount],[Sales Amount])*100)
    RETURN SWITCH(TRUE(),
                                 [From YTD]=BLANK(), 100,

                                  [To YTD]=BLANK(),-100,
                                  result_
                              )