Forum Discussion

LostintheBIu's avatar
LostintheBIu
Helper II
5 years ago
Solved

Create table with missing values compared to previous month

Hello,   I have a table with a project ID, Date and Status. Every month, I add new data under the existing one and I would like to have a table the always compare the last available month in the ta...
  • Greg_Deckler's avatar
    5 years ago

    LostintheBIu - Would need sample data to be specific, but in theory:

    Missing Projects Table = 
      VAR __CurrentMonth = MAX([Date])
      VAR __PreviousMonth = EOMONTH(__CurrentMonth,-1)
      VAR __CurrentTable =
        SELECTCOLUMNS(
          FILTER(
            ALL('Table'),
            YEAR([Date])=YEAR(__CurrentMonth) && MONTH([Date])=MONTH(__CurrentMonth)
          ),
          "Project ID",[ProjectID]
        )
      VAR __PreviousTable =
        SELECTCOLUMNS(
          FILTER(
            ALL('Table'),
            YEAR([Date])=YEAR(__PreviousMonth) && MONTH([Date])=MONTH(__PreviousMonth)
          ),
          "Project ID",[ProjectID]
        )
    RETURN
      EXCEPT(__PreviousTable,__CurrentTable)