Forum Discussion

captainlaw's avatar
captainlaw
Microsoft Employee
9 years ago
Solved

Last N Days

Hello Community, I created a calculated column to return 1 or 0 based on whether the date is within last 28 days. However, as you see from my screenshot below, it's showing all as 1. Below are all t...
  • captainlaw's avatar
    captainlaw
    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