Forum Discussion
DAX Formula for Assign Date
- 6 years ago
Attached below is the PBIX if it helps.
Hi,
check out this support article from Microsoft, it can lead you somewhere near a solution.
https://docs.microsoft.com/en-us/dax/date-and-time-functions-dax
Regards,
Lewis
- Greg_Deckler6 years agoCommunity Champion
Create this column:
MonthNum = MONTH([Date])
and then this column:
AssignDate =
VAR __FirstMonth = MINX(FILTER('Data','Data'[record] = EARLIER('Data'[record])),[MonthNum])
VAR __FirstDate = MINX(FILTER('Data','Data'[record] = EARLIER('Data'[record]) && [MonthNum] = __FirstMonth),[Date])
VAR __CurrentMonthDate = MINX(FILTER('Data','Data'[record] = EARLIER('Data'[record]) && 'Data'[MonthNum] = EARLIER('Data'[MonthNum])),'Data'[Date])
VAR __WhoseOnFirst = IF(__CurrentMonthDate = DATE(YEAR(__CurrentMonthDate),MONTH(__CurrentMonthDate),1),TRUE(),FALSE())
RETURN
SWITCH(TRUE(),
[MonthNum] = __FirstMonth,__FirstDate,
__WhoseOnFirst && __FirstMonth = [MonthNum] - 1,__FirstDate,
MINX(FILTER('Data','Data'[record] = EARLIER('Data'[record]) && [MonthNum] <> __FirstMonth),[Date])
)- Greg_Deckler6 years agoCommunity ChampionSorry, trying to paste that into the code windows was giving me some kind of wonky error.
- Greg_Deckler6 years agoCommunity Champion
Attached below is the PBIX if it helps.