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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
davidr
Frequent Visitor

Comparing the same month from last year

Hello,

 

I need to calculate the percentage difference of the 'Ratio' column (Column B) for the same month from last year.

 

For example: Comparing the 'Ratio' from 202007 (10) to 201907 (11) would be a 9.5% Difference.

 

Any help would be appreciated. Many Thanks.

 

YYYYRatioDate
202007101/07/2020
202006121/06/2020
201907111/07/2019
201906151/06/2019
1 ACCEPTED SOLUTION
pranit828
Community Champion
Community Champion

Hi @davidr 

Create a new column as below

 

_LOOK =
var _val = LOOKUPVALUE('Table'[Ratio], 'Table'[YYYY], FORMAT(left('Table'[YYYY],4),"####")-1 & right('Table'[YYYY],2))
//RETURN _val
RETURN if(ISBLANK(_val),BLANK(),(_val-'Table'[Ratio])/_val)
 
Below is the Output, I don't see 9.5%, you may change the calculation in the above column creation dax formula marked in blue to achieve your desired result.
pranit828_0-1599020421373.png

 





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

View solution in original post

5 REPLIES 5
Icey
Community Support
Community Support

Hi @davidr ,

 

Please let us know if the methods above are helpful.

And if the problem is solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

 

Best Regards,

Icey

pranit828
Community Champion
Community Champion

Hi @davidr 

Create a new column as below

 

_LOOK =
var _val = LOOKUPVALUE('Table'[Ratio], 'Table'[YYYY], FORMAT(left('Table'[YYYY],4),"####")-1 & right('Table'[YYYY],2))
//RETURN _val
RETURN if(ISBLANK(_val),BLANK(),(_val-'Table'[Ratio])/_val)
 
Below is the Output, I don't see 9.5%, you may change the calculation in the above column creation dax formula marked in blue to achieve your desired result.
pranit828_0-1599020421373.png

 





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile
amitchandak
Super User
Super User

@davidr , you can use time intelligence and date table

example

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
last year MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))
diff = [MTD Sales]-[last year MTD Sales]
diff % = divide([MTD Sales]-[last year MTD Sales],[last year MTD Sales])

 

Power BI — MTD
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.

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
mohammedadnant
Impactful Individual
Impactful Individual

@davidr 

 

You can try this DAX measure... 
SPLY =
VAR _SPLYValue = CALCULATE(sum(LastYear[Ratio]), SAMEPERIODLASTYEAR(LastYear[Date]))
VAR _ThisYearValue = SUM(LastYear[Ratio])
VAR _Diff = _SPLYValue-_ThisYearValue
RETURN
IF(_Diff>0,
DIVIDE(_Diff,_SPLYValue,0)*100, "")
 
Thanks and hit the like button,
Mohammed Adnan
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!

Thanks & Regards,
Mohammed Adnan
Learn Power BI: https://www.youtube.com/c/taik18
Greg_Deckler
Super User
Super User

@davidr - There are time "intelligence" functions for this like CALCULATE([somthing],PREVIOUSYEAR())

 

You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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