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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Anonymous
Not applicable

Cumulative measure with slicer that also displays dates prior to slicer (help!)

Hi, I am using our financial weeks in a date table.

 

The date table connects to value date via 'REFUND DATE or SALE DATE using USERRELATIONSHIP and a switch. 

 

Capturehelp.PNG

 

I am trying to visualise cumulative (our financial year YTD) values. 

 

Date structure example for 2020/21 week 8 and 2019/20 week8 )

 

FinYear = Business Financial Year

 

Date_slicer_week table:

FinYearWeekValue (this is the key to the date tableFinYearWeek.Slicer (This is used in the slicer)week value
2021.082021 W088
1920.081920 W088

 

Date_table table:

FinYearWeekValue (this is the key to the date_week slicer)Financial yearweek value
2021.0820218
1920.0819208

 

This are the intial measures I am using for the values

 

 

 

 

Value Calc by Refund Date = CALCULATE(
    SUM('Test_Value'[Value]),
    USERELATIONSHIP(
        Date_Table[Date],
        'Test_Value'[Refund Date]
    )
)

 

 

 

 

 

Value Calc by Sale Date = CALCULATE(
    SUM('Test_Value'[Value]),
    USERELATIONSHIP(
        Date_Table[Date],
        'Test_Value'[Sale Date]
    )
)

 

 

 

 

the switch measure for the value

 

 

 

Value Calc Switch = switch([IND Measure],1,[Value Calc by Refund Date], 2, [Value Calc by Sale Date]) //changes date relationship based on the DATE_TYPE_SWITCH SLICER

 

 

 

 

And this is the cumulative measure (ignore quarter/period for this query)

 

 

YTD Value using Selectedvalue = 
VAR CurrentWeek = SELECTEDVALUE( Date_Table[Week Value] )
VAR CurrentQuarter = SELECTEDVALUE (Date_Table[Quarter Value])
VAR CurrentPeriod = SELECTEDVALUE ( Date_Table[Period Value])
VAR CurrentYear = SELECTEDVALUE( Date_Table[FinYear Value] )

RETURN
CALCULATE( 'Measure Value'[Value Calc Switch],
    FILTER( ALL( Date_Table ),
		Date_Table[Week Value] <= CurrentWeek && Date_Table[FinYear Value] = CurrentYear ))

 

 

 

 

My measure works in the table when I have no slicer applied. Problem (1) I have is in the bar visual the Cumulative(/YTD) measure only displays if I have a 2nd filter to select a single year.

 

Capturehelp2.PNG

My 2nd (and main) problem I have is when I apply the week (2021 W08) slicer the values still calculate correctly but I want it to display the previous weeks. Currently it is just showing the selected week in the slicer. 

 

Capturehelp4.PNG

 

 

n.b. SELECTEDVALUE is a necessity so users can look back in the data history rather than using calculated columns to create ThisYearValue. 

 

 

8 REPLIES 8
Anonymous
Not applicable

Hi, 

 

I'm still stuck with this, can anyone help?

Anonymous
Not applicable

Anonymous
Not applicable

Hi @Anonymous ,

Sorry for my late reply...

For the first question, if you want to display the value only after the slicer2 has been selected , you could use ISFILTERED() function to judge.

For the second question, if you want to display the previous week based on Slicer , you need to create a new table for Slicer which has no relationship with the Date Table.

11.12.1.1.PNG

=
CALCULATE (
    MAX ( 'Table'[Value] ),
    FILTER (
        'Date Table',
        'Date Table'[Week Value] <= SELECTEDVALUE ( 'forSlicer'[Week Slicer] )
    )
)

 

Best regards,

Eyelyn Qin

Anonymous
Not applicable

hi @Eyelyn9 is there anyway else for me to share this with you? I would be very appreciative of any help you can give.

Anonymous
Not applicable

hi @Anonymous 

Sure, can I have your email address please. My organisation prevents use from sharing files using the 'anyone with link' option in onedrive. 

amitchandak
Super User
Super User

@Anonymous , for the week vs previous week you refer to my blog. Make week /date is in a separate table and create week rank and do it.

 

New column

Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)

 

measure
This Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123

 

Week Till Date

YTD= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year]) && 'Date'[Week] <= Max('Date'[Week]) ))
LYTD = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year])-1 && 'Date'[Week] <= Max('Date'[Week])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

YTD= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year]) && 'Date'[Week] <= Max('Date'[Week]) ))

 

This is the measure structure I have but it doesn't show prior weeks when you apply a slicer. 

Anonymous
Not applicable

Hi @Anonymous ,

 

Could your share me with your pbix file from your Onedrive for Business?

 

Best Regards,
Eyelyn Qin

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
Top Kudoed Authors