Forum Discussion

mzienowicz99's avatar
mzienowicz99
Icon for Helper I rankHelper I
4 years ago
Solved

Writing a date filter in a measure

Hello!   I'm working on a report and want to get a variance in quantity of the same brand in two different months. My base table is looking pretty much like this (but it has a lot more columns): ...
  • v-janeyg-msft's avatar
    4 years ago

    Hi, mzienowicz99 

     

    According to your description, I think [activity_month] column is a date column or a string column.

    If it is a date column, you can use [activity_month]=date(2021,10,1). If it is a string column, you can use [activity_month]="2021-10".

    Like this:

    YTY Variance =
    CALCULATE (
        CALCULATE (
            [QTY],
            R2_INDUSTRY[BRAND] = "JOHN DEERE",
            R2_INDUSTRY[ACTIVITY_MONTH] = "2021 - 10" //R2_INDUSTRY[ACTIVITY_MONTH] = date(2021,10,1)
        )
            - (
                CALCULATE (
                    [QTY],
                    R2_INDUSTRY[BRAND] = "JOHN DEERE",
                    R2_INDUSTRY[ACTIVITY_MONTH] = "2020 - 10" //R2_INDUSTRY[ACTIVITY_MONTH] = date(2020,10,1)
                )
            )
    )
    

    Did I answer your question ? Please mark my reply as solution. Thank you very much.
    If not, please feel free to ask me.

     

    Best Regards,
    Community Support Team _ Janey