Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Nice day
I have a database in which material is continuously added as the days go by, I want to have a table that shows me the material, the last date on which the material is loaded, how many days have passed since then and the count of the total material that has been loaded, for example:
Database:
No part | Creation Date | Quantity |
1 | 13/06/2022 | 3 |
1 | 16/06/2022 | 2 |
2 | 06/11/2022 | 1 |
2 | 06/12/2022 | 3 |
2 | 15/06/2022 | 4 |
3 | 06/11/2022 | 3 |
3 | 06/11/2022 | 1 |
3 | 06/12/2022 | 2 |
What I would like to show in the table would be the following taking into account that "Today" is 16/06/2022:
No part | Last Creation Date | total quantity | Counting of days |
1 | 16/06/2022 | 5 | 0 |
2 | 15/06/2022 | 8 | 1 |
3 | 06/12/2022 | 6 | 4 |
There are still many things that I need to learn with Dax so I would appreciate your support with this problem
Solved! Go to Solution.
Hi @FalcoTM ,
Try to create measures like so:
Measure - Total Quantity =
CALCULATE ( SUM ( 'Table'[Quantity] ), ALLEXCEPT ( 'Table', 'Table'[No part] ) )
Measure - Day Counting =
VAR Today_ =
DATE ( 2022, 6, 16 )
RETURN
DATEDIFF ( MAX ( 'Table'[Last Date] ), Today_, DAY )
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Try the following
SumQNty = Sum(MaterialLastDate[Quantity])
Max_Load_Date = max(MaterialLastDate[Creation Date])
DayDiff = DATEDIFF([Max_Load_Date],TODAY(),DAY)-1
Thanks & Regards,
Mohammed Adnan
Lean Power BI: https://www.youtube.com/c/taik18
At the time of entering the formulas it gives me as a result the total sum of all the part numbers as well as the last date obtained, in this way
No part | Creation Date | Quantity | Last Date | Total Quantity | Day Counting |
1 | 13/06/2022 | 3 | 16/06/2022 | 19 | 0 |
1 | 16/06/2022 | 2 | 16/06/2022 | 19 | 0 |
2 | 06/11/2022 | 1 | 16/06/2022 | 19 | 0 |
2 | 06/12/2022 | 3 | 16/06/2022 | 19 | 0 |
2 | 15/06/2022 | 4 | 16/06/2022 | 19 | 0 |
3 | 06/11/2022 | 3 | 16/06/2022 | 19 | 0 |
3 | 06/11/2022 | 1 | 16/06/2022 | 19 | 0 |
3 | 06/12/2022 | 2 | 16/06/2022 | 19 | 0 |
I would like the formula to get me the calculation for each part number in this way
No part | Creation Date | Quantity | Last Date | Total Quantity | Day Counting |
1 | 13/06/2022 | 3 | 16/06/2022 | 5 | 0 |
1 | 16/06/2022 | 2 | 16/06/2022 | 5 | 0 |
2 | 06/11/2022 | 1 | 15/06/2022 | 8 | 1 |
2 | 06/12/2022 | 3 | 15/06/2022 | 8 | 1 |
2 | 15/06/2022 | 4 | 15/06/2022 | 8 | 1 |
3 | 06/11/2022 | 3 | 06/12/2022 | 6 | 4 |
3 | 06/11/2022 | 1 | 06/12/2022 | 6 | 4 |
3 | 06/12/2022 | 2 | 06/12/2022 | 6 | 4 |
On the other hand the formula of the counting of days works correctly
Hi @FalcoTM ,
Try to create measures like so:
Measure - Total Quantity =
CALCULATE ( SUM ( 'Table'[Quantity] ), ALLEXCEPT ( 'Table', 'Table'[No part] ) )
Measure - Day Counting =
VAR Today_ =
DATE ( 2022, 6, 16 )
RETURN
DATEDIFF ( MAX ( 'Table'[Last Date] ), Today_, DAY )
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
79 | |
73 | |
57 | |
36 | |
31 |
User | Count |
---|---|
91 | |
60 | |
60 | |
49 | |
45 |