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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
aks_jo
Frequent Visitor

Calculate variance in same column when filtered by different dates in two month slicers.

I am trying to calculate variance in the same column by using two different month slicers. The DAX gives variance as zero when I am selecting same months but showing blank when different months are selected. Is there any way to calculate row to row subtraction when same column is selected via different month slicers. Also the month column is appended data and has repeated values.

aks_jo_0-1714117308073.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @aks_jo ,

Since you didn't provide sample data, I had to create a sample data myself to test it:

vjunyantmsft_0-1714354936173.png

And I suggest you to add two tables for slicers:

vjunyantmsft_1-1714354969634.pngvjunyantmsft_2-1714354975624.png

Without any relationships:

vjunyantmsft_3-1714354996201.png

Then I use this DAX to create a measure:

Difference = 
VAR Month_From = SELECTEDVALUE(Slicer1[Month_From])
VAR Month_To = SELECTEDVALUE(Slicer2[Month_To])
VAR Value_From = 
CALCULATE(
    SUM('Table'[Actual TPD 1]),
    MONTH('Table'[Date]) = Month_From
)
VAR Value_To =
CALCULATE(
    SUM('Table'[Actual TPD 1]),
    MONTH('Table'[Date]) = Month_To
)
RETURN
Value_From - Value_To

And the final output is as below:

vjunyantmsft_4-1714355054116.png

vjunyantmsft_5-1714355061573.png


Best Regards,
Dino Tao
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

1 REPLY 1
Anonymous
Not applicable

Hi @aks_jo ,

Since you didn't provide sample data, I had to create a sample data myself to test it:

vjunyantmsft_0-1714354936173.png

And I suggest you to add two tables for slicers:

vjunyantmsft_1-1714354969634.pngvjunyantmsft_2-1714354975624.png

Without any relationships:

vjunyantmsft_3-1714354996201.png

Then I use this DAX to create a measure:

Difference = 
VAR Month_From = SELECTEDVALUE(Slicer1[Month_From])
VAR Month_To = SELECTEDVALUE(Slicer2[Month_To])
VAR Value_From = 
CALCULATE(
    SUM('Table'[Actual TPD 1]),
    MONTH('Table'[Date]) = Month_From
)
VAR Value_To =
CALCULATE(
    SUM('Table'[Actual TPD 1]),
    MONTH('Table'[Date]) = Month_To
)
RETURN
Value_From - Value_To

And the final output is as below:

vjunyantmsft_4-1714355054116.png

vjunyantmsft_5-1714355061573.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors