Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Finding the Latest Transaction

I'm new at using Power BI and I need a little help. The goal is to find the latest transaction. For example, I'm a pizza company. I want to show the lifecycle of the latest transaction of making a pizza. How do I portray which action was completed last? Below, you will find current data and expected output. Any advice is appreciated.

 

Here is current data:

Alert_IDStatusTransaction_Date 
1New2/1/2022
1In Progress2/6/2022
1Complete2/9/2022
2New2/1/2022
3New2/2/2022
3Complete2/3/2022

 

Here is the expected output:

Alert_IDStatusTransaction_Date IsLatestTransaction
1New2/1/2022 
1In Progress2/6/2022 
1Complete2/9/20221
2New2/1/20221
3New2/2/2022 
3Complete2/3/20221
  • Hi,

    Please check the below picture and the attached pbix file.

    It is for creating a calculated measure.

     

     

    IsLatestTransaction: =
    VAR currentID =
    MAX ( Data[Alert_ID] )
    VAR currentIDTable =
    FILTER ( ALL ( Data ), Data[Alert_ID] = currentID )
    VAR latestdate =
    MAXX ( currentIDTable, Data[Transaction_Date ] )
    RETURN
    IF ( MAX ( Data[Transaction_Date ] ) = latestdate, 1, "" )
     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thank you so much!!

  • Hi,

    Please check the below picture and the attached pbix file.

    It is for creating a calculated measure.

     

     

    IsLatestTransaction: =
    VAR currentID =
    MAX ( Data[Alert_ID] )
    VAR currentIDTable =
    FILTER ( ALL ( Data ), Data[Alert_ID] = currentID )
    VAR latestdate =
    MAXX ( currentIDTable, Data[Transaction_Date ] )
    RETURN
    IF ( MAX ( Data[Transaction_Date ] ) = latestdate, 1, "" )