cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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

 

Captura.JPG

 

 

_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)

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User IV
Super User IV

Re: PREVIOUSMONTH & DIVIDE ERROR

@rdiazd73 ,

Try like

DIVIDE(([_STOCK 9L]-[_PREV M 9l]);[_PREV M 9l])



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

View solution in original post

Highlighted
Super User IV
Super User IV

Re: PREVIOUSMONTH & DIVIDE ERROR

@rdiazd73 

Previous Month is 0, so % increase is infinity 2/0



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

View solution in original post

4 REPLIES 4
Highlighted
Super User IV
Super User IV

Re: PREVIOUSMONTH & DIVIDE ERROR

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?

---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Super User IV
Super User IV

Re: PREVIOUSMONTH & DIVIDE ERROR

@rdiazd73 ,

Try like

DIVIDE(([_STOCK 9L]-[_PREV M 9l]);[_PREV M 9l])



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

View solution in original post

Highlighted
Frequent Visitor

Re: PREVIOUSMONTH & DIVIDE ERROR

 

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

Captura.JPG

Highlighted
Super User IV
Super User IV

Re: PREVIOUSMONTH & DIVIDE ERROR

@rdiazd73 

Previous Month is 0, so % increase is infinity 2/0



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

View solution in original post

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors