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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
CecilMathew
New Member

Compare any 2 years/month/quarter data

How do I compare any 2 years data i.e. year 2018 data with 2021 data having multiple datasets on single page? I have got the dax query working for year over year comparison but not working for flexible year comparison. If there is a solution please reply .

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @CecilMathew ;

You could create other two date table as slicer, then create a measure to calculate the difference.

1.create two table.

slicer1 = VALUES('Table'[date])
slicer1 = VALUES('Table'[date])

2.create a measure.

differ = 
var _slicer1=CALCULATE(SUM([value]),FILTER(ALL('Table'),YEAR([date])=YEAR( MAX('slicer1'[date]))))
var _slicer2=CALCULATE(SUM([value]),FILTER(ALL('Table'),YEAR([date])=YEAR( MAX('slicer2'[date]))))
return DIVIDE(_slicer2-_slicer1,_slicer1)

The final output is shown below:

vyalanwumsft_0-1638240486578.pngvyalanwumsft_1-1638240496562.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi, @CecilMathew ;

You could create other two date table as slicer, then create a measure to calculate the difference.

1.create two table.

slicer1 = VALUES('Table'[date])
slicer1 = VALUES('Table'[date])

2.create a measure.

differ = 
var _slicer1=CALCULATE(SUM([value]),FILTER(ALL('Table'),YEAR([date])=YEAR( MAX('slicer1'[date]))))
var _slicer2=CALCULATE(SUM([value]),FILTER(ALL('Table'),YEAR([date])=YEAR( MAX('slicer2'[date]))))
return DIVIDE(_slicer2-_slicer1,_slicer1)

The final output is shown below:

vyalanwumsft_0-1638240486578.pngvyalanwumsft_1-1638240496562.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@CecilMathew , Check if these two slicers approaches can help you

How to use two Date/Period slicers :https://www.youtube.com/watch?v=WSeZr_-MiTg

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

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.