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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
RobCook
Regular Visitor

Slicer to affect dynamic filter - if max date less than selected value

Hi all,

 

I'm working with a data set that stored total sales each day, rather than delta. Something I'm working on shifting away from.

I've written a query to calculate the daily movement, but I'm having issues building a visualisation to show the total sales for all products with a date filter/slicer. That's because when products stop being sold they stop being included on the report, but I need them to remain on the visual.

 

Example below:

 

StoreIdProductIdSaleDateUnitsValue
1115/02/2023136612
1114/02/2023123553.5
1113/02/2023120540
1214/02/202354270
1213/02/202348240
1315/02/20235202080
1314/02/20234991996
1313/02/20234721888

 

Product 2 stops being sold on 14/02/2023 so isn't recorded on 15/02/2023, but if the Slicer selects 15/02/2023 I still need product 2 totals to show.

I need a way to have a slicer to select the Sale Date conditionally. If the Max(Sale Date) < SelectedValue then give most recent Sale Date data. Or similar.

 

Apologies if that's poorly explained, it's a very specific scenario/product which is difficult to give examples.

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @RobCook 

 

You can try the following methods.
Table:

Date = CALENDAR(DATE(2023,2,1),DATE(2023,2,28))

Measure:

Measure = 
Var _maxdate=CALCULATE(MAX('Table'[SaleDate]),ALLEXCEPT('Table','Table'[ProductId]))
Var _total=CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),[ProductId]=SELECTEDVALUE('Table'[ProductId])&&[SaleDate]<=SELECTEDVALUE('Date'[Date])))
Return
IF(SELECTEDVALUE('Date'[Date])>=_maxdate,_total)

vzhangti_0-1676872741509.png

Is this the result you expect? If not, please give examples of your desired output?

 

Best Regards,

Community Support Team _Charlotte

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

1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @RobCook 

 

You can try the following methods.
Table:

Date = CALENDAR(DATE(2023,2,1),DATE(2023,2,28))

Measure:

Measure = 
Var _maxdate=CALCULATE(MAX('Table'[SaleDate]),ALLEXCEPT('Table','Table'[ProductId]))
Var _total=CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),[ProductId]=SELECTEDVALUE('Table'[ProductId])&&[SaleDate]<=SELECTEDVALUE('Date'[Date])))
Return
IF(SELECTEDVALUE('Date'[Date])>=_maxdate,_total)

vzhangti_0-1676872741509.png

Is this the result you expect? If not, please give examples of your desired output?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Kudoed Authors