Here is one way - see the attached superstore example
Order date is a filter with a slider - then use window_max to find the last order date in the viz
the formula just looks at the sales for the last 5 days only and set the rest to 0
if DATEDIFF('day',attr([Order Date]),WINDOW_MAX(attr([Order Date])))
<=5 then sum([Sales]) else 0 end
Let me know if this solved your issues
If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution. Thank you.
windowmaxdate.twbx 1.2 MB
I'm not aware of a way to pull the exact end-of-range dates from the filter itself. Tableau doesn't give us those values stored anywhere that I know of.
But you can sort of derive them by calc-ing the MAX value on the sheet and the MIN value on the sheet. However that only gives you the max and min of the rows that fit the range, not the actual range value itself. For example, if you never have data on a Sunday, but if the user selects a date that falls on a sunday, the MAX value you will have on the sheet will be Saturday (or even Friday, if you have no Saturday data.)
And, in fact, that's what Jim demonstrates in his example.