Forum Discussion

mturcotte's avatar
mturcotte
Frequent Visitor
6 years ago
Solved

DAX Measure to count only latest transaction

Hi,   I'm struggling with a fairly simple concept and I need help figuring out the DAX measure to count the Boolean value from the last transaction for every User_ID in the transaction log where a...
  • v-eachen-msft's avatar
    6 years ago

    Hi mturcotte ,

     

    You could create the following three measures to get the result:

     

    CountID =
    VAR a =
        IF (
            SELECTEDVALUE ( 'Table'[Date] )
                = CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT ( 'Table', 'Table'[User_Id] ) ),
            1,
            0
        )
    RETURN
        COUNTX ( 'Table', a )

     

    Status =
    VAR a =
        IF (
            SELECTEDVALUE ( 'Table'[Date] )
                = CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT ( 'Table', 'Table'[User_Id] ) ),
            1,
            0
        )
    RETURN
        a
    TotalCount = 
    SUMX('Table',[Status])

    Here is the result :

    Here is my test file for your reference.