Forum Discussion
Group table by max date and categories
Hey everybody,
I have a table with a deal ID, a customer, a product and a date (valid until). A customer can have several deals with the same product therefore I need an aggreagegated table which contains only the max date of the product / customer combination, the customer and the product - needs to be somehow an aggregate. Any Idea how to solve this challenge? Guess the Summarize columns / Group by is the right choice!
| Customer | Product | Deal ID | Valid until |
| A | B | #1 | 31.06.2022 |
| A | B | #1 | 31.12.2022 |
C | A | #1 | 31.01.2022 |
C | A | #1 | 31.06.2022 |
To:
| Customer | Product | Deal ID | Valid until |
| A | B | #1 | 31.12.2022 |
C | A | #1 | 31.06.2022 |
Aggregate table to those lines with the max date.
Hi, lennardheyder
Try to create a calculated table as below:
Table2 = GROUPBY ( Table1, Table1[Customer], Table1[Deal ID], Table1[Product], "Max Date", MAXX ( CURRENTGROUP (), MAX ( Table1[Valid until] ) ) )or
Table3 = SUMMARIZE( Table1, Table1[Customer], Table1[Deal ID], Table1[Product], "Max Date", MAX ( Table1[Valid until] ) )Best Regards,
Community Support Team _ Eason
3 Replies
- VahidDM
Super User
Can you post sample data as text and expected output?
Not enough information to go on;
please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
4. Relation between your tables
Appreciate your Kudos!!
LinkedIn:www.linkedin.com/in/vahid-dm/- lennardheyderFrequent Visitor
Hey Vahid, I attached a table of the status quo and the target table. Thanks for the hint!
- v-easonf-msft
Community Support
Hi, lennardheyder
Try to create a calculated table as below:
Table2 = GROUPBY ( Table1, Table1[Customer], Table1[Deal ID], Table1[Product], "Max Date", MAXX ( CURRENTGROUP (), MAX ( Table1[Valid until] ) ) )or
Table3 = SUMMARIZE( Table1, Table1[Customer], Table1[Deal ID], Table1[Product], "Max Date", MAX ( Table1[Valid until] ) )Best Regards,
Community Support Team _ Eason