cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper I

## PREVIOUSMONTH & DIVIDE ERROR

Hello guys

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)

2 ACCEPTED SOLUTIONS
Super User

Try like

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

Super User

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

4 REPLIES 4
Super User

Try like

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

Helper I

Hi
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

Super User

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

Super User
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?

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

#### Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors