Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have a dataset A with the following columns:
Objective:
Calculate the number of days matching the Max(Date) for each Product_Code.
Date Product_Code Type Group
01/01/2024 | A | Y | M |
02/01/2024 | B | Y | M |
03/01/2024 | C | X | M |
04/01/2024 | A | X | M |
05/01/2024 | B | X | N |
06/01/2024 | C | X | N |
07/01/2024 | A | Y | N |
08/01/2024 | B | Y | N |
Type Group Max_Date_By_Type_Group Product_Code
Y | M | 02/01/2024 | B |
X | M | 04/01/2024 | A |
X | N | 06/01/2024 | C |
Y | N | 08/01/2024 | B |
Product_Code Amount_Date
A | 1 |
B | 2 |
C | 1 |
Type Group Max_Date_By_Type_Group Product_Code
Y | M | 02/01/2024 | B |
X | M | 04/01/2024 | A |
X | N | 06/01/2024 | C |
Y | N | 07/01/2024 | A |
Product_Code Amount_Date
A | 2 |
B | 1 |
C | 1 |
How can I implement this in Power BI? Specifically, I need help with:
Any suggestions or DAX solutions would be greatly appreciated!
Solved! Go to Solution.
Hi @chuongnq - We need to calculate the maximum date for each combination of Type and Group within the selected date range.
create a calculated table for typegroup as below with summarize function :
To retrieve the corresponding Product_Code for the calculated Max_Date_By_Type_Group
Now, create a measure to calculate the number of days matching Max_Date_By_Type_Group for each Product_Code:
output:
Hope this helps.
Proud to be a Super User! | |
Hi @chuongnq - We need to calculate the maximum date for each combination of Type and Group within the selected date range.
create a calculated table for typegroup as below with summarize function :
To retrieve the corresponding Product_Code for the calculated Max_Date_By_Type_Group
Now, create a measure to calculate the number of days matching Max_Date_By_Type_Group for each Product_Code:
output:
Hope this helps.
Proud to be a Super User! | |
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
73 | |
71 | |
38 | |
29 | |
28 |
User | Count |
---|---|
99 | |
88 | |
62 | |
42 | |
39 |