Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

DAX Help

I would like to create DAX which pulls last 12 Months data based on selected date.   Example: If user selects the current date June 10th ,2021 ,it should display last 12 months of data along with ...
  • Anonymous's avatar
    Anonymous
    5 years ago

    HI Anonymous,

    I'd like to suggest you create a measure filter with custom expressions to filter records and use it on the visual level filter.

    Applying a measure filter in Power BI - SQLBI

    Measure =
    VAR selected =
        MAX ( NewTable[Date] )
    RETURN
        IF (
            MAX ( Table[Date] )
                IN CALENDAR (
                    DATE ( YEAR ( selected ) - 1, MONTH ( selected ), DAY ( selected ) ),
                    selected
                ),
            1,
            0
        )

    Regards,

    Xiaoxin Sheng