Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Can't get DAX to Find Values Filtering by Date

Hi everyone A relatively straightforward problem I'm having here: I have a table called Market Moves which is set up a little like this and is filtered in Power Query by the PRICEDATE column in dec...
  • v-kkf-msft's avatar
    4 years ago

    Hi Anonymous ,

     

    Please try the following measures:

     

    LastDate = 
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER ( ALLSELECTED ( 'Table'[Date] ), 'Table'[Date] >= MAX ( 'Table'[Date] ) )
    )
    most recent price = 
    CALCULATE (
        SUM ( 'Table'[Price] ),
        FILTER ( ALLSELECTED ( 'Table'[Date] ), 'Table'[Date] = [LastDate] )
    )
    second most recent price = 
    VAR seconddate =
        CALCULATE (
            MAX ( 'Table'[Date] ),
            FILTER ( ALLSELECTED ( 'Table'[Date] ), 'Table'[Date] <> [LastDate] )
        )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Price] ),
            FILTER ( ALLSELECTED ( 'Table'[Date] ), 'Table'[Date] = seconddate )
        )
    last date of last year = 
    CALCULATE (
        SUM ( 'Table'[Price] ),
        ALL ( 'Table' ),
        LASTDATE ( ALLSELECTED ( 'Table'[Date] ) )
    )
    b- a = [second most recent price] - [most recent price]
    c - a = [last date of last year] - [most recent price]

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.