Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
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.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.