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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
MesserAmericas
New Member

Month over Month Variance fails to update when filter/slicer applied to table

I am comparing overtime per month at 100+ locations, the OT and OT last month update when slicer / filter by location is selected, however the variance and variance % do not reflect the change. It continues to return total value of OT for the entire month for all locations.

How can I fix my formula to update by location when filtered for accurate reporting?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @MesserAmericas,

You can try to use the following formula to extract the current date value to calculate.

formula =
VAR currDate =
    MAX ( 'Date'[Date] )
VAR prevDate =
    DATE ( YEAR ( currDate ), MONTH ( currDate ) - 1, DAY ( currDate ) )
VAR cmOT =
    SUM ( Table[OT] )
VAR pmOT =
    CALCULATE (
        SUM ( Table[OT] ),
        FILTER (
            ALLSELECTED ( Table ),
            YEAR ( [Date] ) = YEAR ( prevDate )
                && MONTH ( [Date] ) = MONTH ( prevDate )
        )
    )
RETURN
    cmOT - pmOT

Regards,

Xiaoxin Sheng

View solution in original post

7 REPLIES 7
PaulDBrown
Community Champion
Community Champion

Try the following:

Sum OT = SUM (Table[OT])

 

Prev Month OT = CALCUALTE([Sum OT], DATEADD(Date Table[Date], -1, DAY))

 

OT Month Var = [Sum OT] - [Prev Month OT]





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PaulDBrown
Community Champion
Community Champion

how is the model set up? Do you have a Date Table?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Yes I have a date table. 

Were you able to understand the sample data. My formula does not contain any notes regarding Filter. I am new to power BI

PaulDBrown
Community Champion
Community Champion

please provide sample data or PBIX file, a depcition of the expected output and the code for the measure you have





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Sample data OT by month, when slicing by location the variance pulls entire total.

MonthLocationOT
JanuaryLocA500
JanuaryLocB1300
JanuaryLocC1100
JanuaryLocD200
JanuaryLocE0
JanuaryLocF1700
FebruaryLocA0
FebruaryLocB2500
FebruaryLocC7000
FebruaryLocD2
FebruaryLocE1600
FebruaryLocF400
MarchLocA600
MarchLocB1000
MarchLocC0
MarchLocD500
MarchLocE250
MarchLocF500

 

Formula : OT MoM Var = OT Last Month - OT Sum

MesserAmericas_1-1654704485351.png

 

 

Anonymous
Not applicable

Hi @MesserAmericas,

You can try to use the following formula to extract the current date value to calculate.

formula =
VAR currDate =
    MAX ( 'Date'[Date] )
VAR prevDate =
    DATE ( YEAR ( currDate ), MONTH ( currDate ) - 1, DAY ( currDate ) )
VAR cmOT =
    SUM ( Table[OT] )
VAR pmOT =
    CALCULATE (
        SUM ( Table[OT] ),
        FILTER (
            ALLSELECTED ( Table ),
            YEAR ( [Date] ) = YEAR ( prevDate )
                && MONTH ( [Date] ) = MONTH ( prevDate )
        )
    )
RETURN
    cmOT - pmOT

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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 Solution Authors