Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
rdiazd73
Helper I
Helper I

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

@rdiazd73 ,

Try like

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

@rdiazd73 

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@rdiazd73 ,

Try like

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

 

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

@rdiazd73 

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Greg_Deckler
Super User
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?


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.