Forum Discussion
Create a table with latest transaction
Hi everyone,
I'm quite new to PowerBI and struggling with something.
I have a table with:
PurchaseOrderNumber
ItemNumber
Date of creation
This table has all POs ever made for that item number.
I need to have a table with only the latest transaction of a certain item. Something like this:
| PurchaseOrderNumber | Item | Date created | PurchaseOrderNumber | Item | Date created | |
| 1 | A | 1/1/2020 | 1 | A | 1/1/2020 | |
| 1 | C | 1/1/2020 | 2 | B | 1/2/2020 | |
| 1 | E | 1/1/2020 | 1 | C | 1/1/2020 | |
| 1 | F | 1/1/2020 | 4 | D | 1/3/2020 | |
| 2 | A | 1/2/2020 | 1 | E | 1/1/2020 | |
| 2 | B | 1/2/2020 | 1 | F | 1/1/2020 | |
| 2 | E | 1/2/2020 | ||||
| 2 | F | 1/2/2020 | ||||
| 3 | A | 1/2/2020 | ||||
| 3 | B | 1/2/2020 | ||||
| 3 | C | 1/2/2020 | ||||
| 4 | A | 1/3/2020 | ||||
| 4 | B | 1/3/2020 | ||||
| 4 | C | 1/3/2020 | ||||
| 4 | D | 1/3/2020 |
The right table would be my result.
Thank you!
5 Replies
- edhansCommunity Champion
Hi Anonymous - I answered one that I think is almost exactly like this yesterday, and included a PBIX file to play with. Take a look and see if that answers your question.
If not, let me know what the diffference is in the scenarios and we will try to help you tweak those DAX measures here to fit your situation.- AnonymousNot applicable
I tried based on that solution, but couldn't make it work 😪
In my case I only have one table with all data, and I just want to create a new table (not measure) showing only the latest transactions of that list.
I tried SUMMARIZE with filter, but couldn't make it work. Also tried SELECTEDCOLUMNS and nothing.
- edhansCommunity Champion
Ok. The following creates a table:
Summarized Table = SUMMARIZECOLUMNS( 'Purchase Data'[Item], "PO ",MAX('Purchase Data'[PurchaseOrderNumber]), "Date", LASTDATE('Purchase Data'[Date created]) )But the results seem to be what you explained, but it isn't the same as your sample table.
In other words, you said "I need to have a table with only the latest transaction of a certain item. Something like this" but then for item A you picked PO #1 on Jan 1, 2020, but item A was purchased on PO #4 on Jan 3, which is the latest transaction.
If this isn't right, can you please clarify?