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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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