Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Weird Previousmonth behavior

Hi Guys,   I am trying to do a Count of X (submit dates) of the previous month.  I have a date table linked to the dates I am interested in in the fact table: the relationship is okay and I can dr...
  • v-frfei-msft's avatar
    v-frfei-msft
    7 years ago

    Hi Anonymous ,

     

    In your scenario, we cannot use previousmonth or dateadd. As for both fucntion, we can get the date by the current row, However in a card visual, there is no filter like a table visual. That's why we got incorrect result by that way. So we can use EDATE to work on it that the logic is slmilar to your work around.

    previous =
    VAR a =
        FORMAT ( EDATE ( TODAY (), -1 ), "yyyymmm" )
    RETURN
        CALCULATE (
            SUM ( 'Table'[value] ),
            FILTER ( 'Table', FORMAT ( 'Table'[date], "yyyymmm" ) = a )
        )