Forum Discussion
Dynamic anchor date to always select max date
- Anonymous4 years ago
Hi reboundgt9 ,
I think you want to show data between last Wednesday to Tuesday. For example, today = 2021/12/21(Tuesday), you will update your data between 2021/12/15 to 2021/12/21 on 2021/12/22 (Wednesday). So today you still want to get data between 2021/12/08 to 2021/12/14. Here I suggest you to create a weekgroup column in your date table and then create a filter measure to filter your visual.
My Date table:
Date = ADDCOLUMNS ( CALENDAR ( DATE ( 2020, 01, 01 ), DATE ( 2021, 12, 31 ) ), "Year", YEAR ( [Date] ), "Month", MONTH ( [Date] ), "Day", DAY ( [Date] ), "DayName", FORMAT ( [Date], "DDDD" ) )Weekgroup Column:
WeekGroup = CALCULATE ( COUNT ( 'Date'[DayName] ), FILTER ( 'Date', 'Date'[Date] <= EARLIER ( 'Date'[Date] ) && 'Date'[DayName] = "Wednesday" ) )Measure:
Filter = VAR _WeekGroup = CALCULATE ( SUM ( 'Date'[WeekGroup] ), 'Date'[Date] = TODAY () ) RETURN IF ( SUM ( 'Date'[WeekGroup] ) = _WeekGroup - 1, 1, 0 )Add this measure into filter field in your visual and set it to show items when the value is 1. Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi reboundgt9 ,
I think you want to show data between last Wednesday to Tuesday. For example, today = 2021/12/21(Tuesday), you will update your data between 2021/12/15 to 2021/12/21 on 2021/12/22 (Wednesday). So today you still want to get data between 2021/12/08 to 2021/12/14. Here I suggest you to create a weekgroup column in your date table and then create a filter measure to filter your visual.
My Date table:
Date =
ADDCOLUMNS (
CALENDAR ( DATE ( 2020, 01, 01 ), DATE ( 2021, 12, 31 ) ),
"Year", YEAR ( [Date] ),
"Month", MONTH ( [Date] ),
"Day", DAY ( [Date] ),
"DayName", FORMAT ( [Date], "DDDD" )
)
Weekgroup Column:
WeekGroup =
CALCULATE (
COUNT ( 'Date'[DayName] ),
FILTER (
'Date',
'Date'[Date] <= EARLIER ( 'Date'[Date] )
&& 'Date'[DayName] = "Wednesday"
)
)
Measure:
Filter =
VAR _WeekGroup =
CALCULATE ( SUM ( 'Date'[WeekGroup] ), 'Date'[Date] = TODAY () )
RETURN
IF ( SUM ( 'Date'[WeekGroup] ) = _WeekGroup - 1, 1, 0 )
Add this measure into filter field in your visual and set it to show items when the value is 1. Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.