Forum Discussion
Last N Days
- 9 years ago
I knew it shouldn't be that hard - firstnonblank, calculatetable - all those are not needed.
Fixed my own trouble simply by switching column to measure.
maxdate=lastdate(all('calendar'[lawcalendarfull]))
mindate=dateadd(lastdate(all('calendar'[lawcalendarfull])),-6,day)
last7=if(calendar[lawcalendarfull]>=calendar[lawmindate]&&calendar[lawcalendarfull]<=calendar[lawmaxdate],1,0
Any idea on this blank DAX that I'm experiencing? I can attach the pbix file if it helps.
Hi captainlaw,
Could you try the formula below to see if it works.:smileyhappy:
Measure =
VAR LAWMaxDate =
LASTDATE ( ALL ( 'calendar'[LAWCalendarFull] ) )
RETURN
FIRSTNONBLANK (
CALCULATETABLE (
DATEADD ( 'calendar'[LAWCalendarFull], -6, DAY ),
FILTER ( calendar, 'calendar'[LAWCalendarFull] = LAWMaxDate )
),
1
)
Regards
- captainlaw9 years agoMicrosoft Employee
It works! But I'm not aware of the logic of the "blank" in the previous metric. Why would it show blank when LAWMaxDate has value? Does it mean CALCULATETABLE is required? How do you determine if it is required or not?
- captainlaw9 years agoMicrosoft Employee
I knew it shouldn't be that hard - firstnonblank, calculatetable - all those are not needed.
Fixed my own trouble simply by switching column to measure.
maxdate=lastdate(all('calendar'[lawcalendarfull]))
mindate=dateadd(lastdate(all('calendar'[lawcalendarfull])),-6,day)
last7=if(calendar[lawcalendarfull]>=calendar[lawmindate]&&calendar[lawcalendarfull]<=calendar[lawmaxdate],1,0