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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
joshua1990
Post Prodigy
Post Prodigy

Show Past based on selected Week

Hi experts!

I have a simple bar chart that shows our Sales per Week.

Now I would like to add a slicer / filter to select the last week that should be include into the chart.

For instance, when I select Week 22 I just want to see all sales until week 22.

How can I do this using dax?

THis approach doesn't work:

CALCULATE (
        [Sales],
        FILTER (
            ALL ( 'Calendar' ),
            'Calendar'[Year] = VALUES ( 'Calendar'[Year] )
                && 'Calendar'[Week] <= MAX ( 'Calendar'[Week] )
        )
    )
1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

Sales up to week =
var maxDate = MAX('Calendar'[Date])
return CALCULATE( [Sales], REMOVEFILTERS('Calendar'), 'Calendar'[Date] <= maxDate )

View solution in original post

5 REPLIES 5
johnt75
Super User
Super User

Use Performance Analyser to get the DAX code generated for the visual, check what filters are being applied in there.

johnt75
Super User
Super User

Try

Sales up to week =
var maxDate = MAX('Calendar'[Date])
return CALCULATE( [Sales], REMOVEFILTERS('Calendar'), 'Calendar'[Date] <= maxDate )

Ok, I have found the issue.

Now I get the sum of all past weeks display in the selected week.

Just 1 week is displayed in the visual but is sums all past weeks. How can I get the value per week for each week?

I would think your normal [Sales] measure would do that

Thanks @johnt75 , bot nothing changes. I still see just 1 week if I filter on the slicer on 1 week.

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.