Return True for MAX value in column when table filtered by condition - PowerBI DAX

31 Views Asked by At

I have a table of reporting months where i need to create a column 'IsCurrentMonth' that returns true for the current reporting month and false for every other month. The reporting period rolls over on the 7th working day of each month to begin reporting on the month before (e.g. on working day 7 of Feb24, Jan24 become reporting period). I have the majority of the dax working which returns True for all months where the data is available (e.g. on working day 7 of Feb24, all months up to Jan24 show True else they are False. However, I want to only show Jan24 as True rather than all of the preceding months as well.

Any help appreciated. Thanks

enter image description here

enter image description here

enter image description here

1

There are 1 best solutions below

0
Sam Nseir On

Try a different approach of determining when the reporting date is of the current month (of today's date), if the today's date is greater then go back a month, if it is less, then go back two months.

Try:

IsCurrentMonth = 
  var todayMonthStartOf = EOMONTH(TODAY(), -1) + 1
  var daysOffset = 
    SWITCH(
      WEEKDAY(todayMonthStartOf, 1), 
      // Fri
      5, 10,
      // Sat
      6, 10,
      // Sun
      7, 9,
      // others
      8
  )
  var todayMonthRolloverDate = todayMonthStartOf + daysOffset
  var reportingMonthDiff = IF(TODAY() > todayMonthRolloverDate, -1, -2)
  var reportingMonth = EOMONTH(todayMonthStartOf, reportingMonthDiff - 1) + 1
  return [Date] = reportingMonth