Forum Discussion
HELP! Calculate occurrence dynamically based on date slicer
- Anonymous4 years ago
Hi jts_ ,
Here's my solution.
1.Create a calendar table.
Calendar = CALENDAR(DATE(2022,1,1),DATE(2022,12,31))2.Create a slicer for the max date.
3.Create another measure for counting the visits.
Visit Counts = CALCULATE ( COUNT ( 'Table'[Customer ID] ), FILTER ( ALLSELECTED ( 'Table' ), [Customer ID] = MAX ( 'Table'[Customer ID] ) && [Visit Date] >= SELECTEDVALUE ( 'Calendar'[MaxDate] ) - 60 && [Visit Date] <= SELECTEDVALUE ( 'Calendar'[MaxDate] ) ) )4.Create a table visual.
When the max date is 6/30/2022,
When the max date is 5/31/2022,
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Create a Calendar Table and a relationship (Many to One and Single) from the Visit Date column of the Data Table to the Date column of the Calendar Table. To your slicer visual, drag the Date from the Calendar Table. To your Table visual, drag the CustomerID. Write this measure
Measure 1 = calculate(countrows(Data),datesbetween(calendar[date],max(calendar[date])-59,max(calendar[date])))
Hope this helps.