cancel
Showing results for
Did you mean:

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

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
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:

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.

2 REPLIES 2
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:

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.

Super User

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