Forum Discussion
Anonymous
4 years agoNot applicable
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_ID | Status | Transaction_Date |
| 1 | New | 2/1/2022 |
| 1 | In Progress | 2/6/2022 |
| 1 | Complete | 2/9/2022 |
| 2 | New | 2/1/2022 |
| 3 | New | 2/2/2022 |
| 3 | Complete | 2/3/2022 |
Here is the expected output:
| Alert_ID | Status | Transaction_Date | IsLatestTransaction |
| 1 | New | 2/1/2022 | |
| 1 | In Progress | 2/6/2022 | |
| 1 | Complete | 2/9/2022 | 1 |
| 2 | New | 2/1/2022 | 1 |
| 3 | New | 2/2/2022 | |
| 3 | Complete | 2/3/2022 | 1 |
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 ] )RETURNIF ( MAX ( Data[Transaction_Date ] ) = latestdate, 1, "" )
2 Replies
- AnonymousNot applicable
Thank you so much!!
- Jihwan_KimSuper User
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 ] )RETURNIF ( MAX ( Data[Transaction_Date ] ) = latestdate, 1, "" )