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

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

Reply
Krisvenkata11
Frequent Visitor

Calculate variance between 2 weeks

 

I am looking to calculate the dax query  some thing like below(Measure or column). Variance should be the output which is difference the weeks like diff between week2 and week1 is -1

WeekSalesVariance
166
25-1
383
47-1
54-3
63-1
72-1
80-2
91010
10122
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Krisvenkata11 ,

 

You can create a measure like below to calculate variance between 2 weeks :

 

Variance =
VAR cur_week =
    MIN ( Sheet1[Week] )
VAR previous_week =
    CALCULATE (
        MAX ( Sheet1[Week] ),
        FILTER ( ALL ( Sheet1 ), Sheet1[Week] < cur_week )
    )
VAR cur_sales =
    MIN ( Sheet1[Sales] )
VAR previous_sales =
    CALCULATE (
        MAX ( Sheet1[Sales] ),
        FILTER ( ALL ( Sheet1 ), Sheet1[Week] = previous_week )
    )
RETURN
    cur_sales - previous_sales

 

vbinbinyumsft_0-1657527831464.png

 

 

Best regards,
Community Support Team_ Binbin Yu
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
Anonymous
Not applicable

Hi @Krisvenkata11 ,

 

You can create a measure like below to calculate variance between 2 weeks :

 

Variance =
VAR cur_week =
    MIN ( Sheet1[Week] )
VAR previous_week =
    CALCULATE (
        MAX ( Sheet1[Week] ),
        FILTER ( ALL ( Sheet1 ), Sheet1[Week] < cur_week )
    )
VAR cur_sales =
    MIN ( Sheet1[Sales] )
VAR previous_sales =
    CALCULATE (
        MAX ( Sheet1[Sales] ),
        FILTER ( ALL ( Sheet1 ), Sheet1[Week] = previous_week )
    )
RETURN
    cur_sales - previous_sales

 

vbinbinyumsft_0-1657527831464.png

 

 

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

Jos_Woolley
Solution Sage
Solution Sage

Hi,

As a measure:

MyMeasure =
VAR ThisWeek =
    MIN( 'Table'[Week] )
VAR PreviousWeek =
    CALCULATE(
        MAX( 'Table'[Week] ),
        FILTER( ALLSELECTED( 'Table' ), 'Table'[Week] < ThisWeek )
    )
VAR ThisSales =
    MIN( 'Table'[Sales] )
VAR PreviousSales =
    CALCULATE(
        MIN( 'Table'[Sales] ),
        FILTER( ALLSELECTED( 'Table' ), 'Table'[Week] = PreviousWeek )
    )
RETURN
    ThisSales - PreviousSales

Regards

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.