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
Chazzo
New Member

How to display current week vs previous week % variance on a card when slicer has only 1 selection

Hello All,

 

I'm new to to the forum/new to using DAX and am having difficulties in displaying week over week % variance on a PBI card when only 1 week is slected in my slicer. 

 

My objective is to show current week vs previous week % variance based on the users week selection.  For example, if week 23 is selected in the week slicer, I want to compare week 23 vs week 22 and display % variance on the card.

 

If there are no filters on the week slicer, or non consecutive weeks selected, I want to display the max week vs the previous week % variance on the card.

 

Below are the DAX formulas I have for current week and previous week.  When selecting 1 week in my slicer, my result is returning (Blank).  I belive this is simply because Previous week result is being filtered out. 

 

Thank you in advance for any solutions you may have to offer!

 

Chazzo_1-1722197787180.png  

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @Chazzo 

Thanks for @aduguid positive reply. You can try this measure to solve your need.

vyaningymsft_0-1722491929598.pngvyaningymsft_1-1722491981812.pngvyaningymsft_2-1722491999678.png

 

Measure:

% Sales = 
VAR _maxSelectedWeekNum =
    CALCULATE ( MAX ( 'Week slicer'[WeekNum] ) )
VAR _currentWeekSales =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        'Table'[WeekNum] = _maxSelectedWeekNum
    )
VAR _previousWeekSales =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        'Table'[WeekNum] = _maxSelectedWeekNum - 1
    )
VAR _result =
    DIVIDE ( _currentWeekSales, _previousWeekSales )
RETURN
    _result

 

Best Regards,
Yang

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, @Chazzo 

Thanks for @aduguid positive reply. You can try this measure to solve your need.

vyaningymsft_0-1722491929598.pngvyaningymsft_1-1722491981812.pngvyaningymsft_2-1722491999678.png

 

Measure:

% Sales = 
VAR _maxSelectedWeekNum =
    CALCULATE ( MAX ( 'Week slicer'[WeekNum] ) )
VAR _currentWeekSales =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        'Table'[WeekNum] = _maxSelectedWeekNum
    )
VAR _previousWeekSales =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        'Table'[WeekNum] = _maxSelectedWeekNum - 1
    )
VAR _result =
    DIVIDE ( _currentWeekSales, _previousWeekSales )
RETURN
    _result

 

Best Regards,
Yang

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

aduguid
Super User
Super User

Try this measure

 

WeekOverWeekVariance = 
VAR SelectedWeek = SELECTEDVALUE(tbl_FF[Week])
VAR MaxWeek = MAX(tbl_FF[Week])
VAR CurrentWeekValue = 
    CALCULATE(
        [_Tot Sales TY],
        tbl_FF[Week] = SelectedWeek
    )
VAR PreviousWeek = 
    IF(
        ISBLANK(SelectedWeek),
        CALCULATE(
            MAX(tbl_FF[Week]),
            FILTER(
                ALL(tbl_FF),
                tbl_FF[Week] < MaxWeek
            )
        ),
        SelectedWeek - 1
    )
VAR PreviousWeekValue = 
    CALCULATE(
        [_Tot Sales TY],
        tbl_FF[Week] = PreviousWeek
    )
RETURN
IF(
    ISBLANK(CurrentWeekValue) || ISBLANK(PreviousWeekValue),
    BLANK(),
    DIVIDE(CurrentWeekValue - PreviousWeekValue, PreviousWeekValue, 0)
)

 

Hi Aduguid,

 

This measure is working great when selecting a single week (thank you so much!).

The part that doesn't seem to be working is:

"If there are no filters on the week slicer, or non consecutive weeks selected, I want to display the max week vs the previous week % variance on the card."

 

Do you have a suggestion on how I might modify the measure to show the variance of the max week vs previous when slicer has no filter or multiple weeks selected?

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