Forum Discussion

rdiazd73's avatar
rdiazd73
Icon for Helper I rankHelper I
6 years ago
Solved

PREVIOUSMONTH & DIVIDE ERROR

Hello guys
thanks in advance for your help

I need the percentage of growth or decrease from one month to another, the problem appears when the stock of the previous month is 0, it does not calculate well, can you help me thanks

 

 

 

_PREV M 9l =
CALCULATE(SUM('STOCKS ES FERT'[9L]);
PREVIOUSMONTH('FiscalCalendar II'[Date]))

 

_STOCK 9L = SUMX('STOCKS ES FERT';
'STOCKS ES FERT'[9L])


_% PREV M 9l =
IF(SUM('STOCKS ES FERT'[9L])>0;
DIVIDE(SUMX('STOCKS ES FERT';[_STOCK 9L]);
CALCULATE(SUM('STOCKS ES FERT'[9L]);
PREVIOUSMONTH('FiscalCalendar II'[Date])))-1)

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion
    Right, because it is dividing by zero,but it looks like you are using the third parameter of the DIVIDE function to account for this kind of error, right? Maybe just try 0 in that third parameter?
    • rdiazd73's avatar
      rdiazd73
      Icon for Helper I rankHelper I

       

      Hi
      thanks for your help
      your formula partially fixes the error, ok the erroneous percentage disappears,

      but it should propose a growth percentage stock previous month 0 current stock 2 percentage increase + 200%, no ?

      thanks