Forum Discussion
Date Grouping based on MOST RECENT dates
- 5 years ago
Try this calculated column:
4 Weeks Ended = VAR vMaxDate = MAX ( Sales[Period] ) VAR vDaysDiff = CONVERT ( vMaxDate - Sales[Period], INTEGER ) VAR vDelta = ROUNDDOWN ( DIVIDE ( vDaysDiff, 28 ), 0 ) VAR vResult = vMaxDate - ( vDelta * 28 ) RETURN vResult
Hi,
This calculated column formula seems to work
=CALCULATE(MAX(Table1[Period]),FILTER(Table1,Table1[Brand]=EARLIER(Table1[Brand])&&Table1[Period]<=EARLIER(Table1[Period])+21))
Hope this helps.
Try this calculated column:
4 Weeks Ended =
VAR vMaxDate =
MAX ( Sales[Period] )
VAR vDaysDiff =
CONVERT ( vMaxDate - Sales[Period], INTEGER )
VAR vDelta =
ROUNDDOWN ( DIVIDE ( vDaysDiff, 28 ), 0 )
VAR vResult = vMaxDate - ( vDelta * 28 )
RETURN
vResult
- ryan_b_fiting5 years ago
Post Patron
DataInsights this one does work for almost everything I need. The only time it will not work is if we are selecting a specified date range that does not include the most recent period of data. For example if we have data through November 1, 2020. But I wanted to look to see what my numbers were for 2019 through the same week number in November, this will not dynamically adjust the groupings based on that.
Other than that, this solves everything I asked for, so I am marking it as the solution.
Thanks a ton for your help DataInsights
- DataInsights5 years ago
Super User
Try this measure. It requires the following:
1. Slicer based on the Date table.
2. A relationship between the Sales and Date tables.
4 Weeks Ended Measure = VAR vMaxDate = LASTDATE ( ALLSELECTED ( 'Date'[Date] ) ) VAR vCurrentDate = MAX ( Sales[Period] ) VAR vDaysDiff = CONVERT ( vMaxDate - vCurrentDate, INTEGER ) VAR vDelta = ROUNDDOWN ( DIVIDE ( vDaysDiff, 28 ), 0 ) VAR vResult = vMaxDate - ( vDelta * 28 ) RETURN IF ( ISBLANK ( vCurrentDate ), BLANK (), vResult )