简体   繁体   中英

Dax Measure to show previous month

I have a table that shows as this:

AccountingMonth | AccountingYear | MonthType
January         | 2019           | Other
February        | 2019           | Other
March           | 2019           | Other
April           | 2019           | Other
May             | 2019           | Other
June            | 2019           | Other
July            | 2019           | Other
August          | 2019           | Other
September       | 2019           | Other
October         | 2019           | Other
November        | 2019           | Other
December        | 2019           | Other
January         | 2020           | Other
February        | 2020           | Previous Month
March           | 2020           | Current Month
April           | 2020           | Next Month

I am trying to create a measure to just select the previous month. How do I filter using VALUES?

GaugePreviousMonthTitle =
VAR SelectedValues =
    VALUES ( Budget[AccountingMonth] ) ------filter for MonthType of Previous Year???
RETURN
    SelectedValues
GaugePreviousMonthTitle =
CALCULATE(
    VALUES ( Budget[AccountingMonth] ), 
    Budget[MonthType]="Pevious Month"
   )

An assumption here is that "Previous Month" flag is always unique in the table, and thus will always return only one AccountingMonth. If that's not true, you will need to protect the result from returning multiple values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM