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
Hello,
Can someone please help me solve the following query, I have got the following table -
| Date | Sales | 
| 24-05-2024 | 100 | 
| 24-05-2024 | 100 | 
| 27-05-2024 | 200 | 
| 27-05-2024 | 200 | 
| 27-05-2024 | 200 | 
| 27-05-2024 | 200 | 
| 27-05-2024 | 200 | 
| 28-05-2024 | 300 | 
| 28-05-2024 | 300 | 
| 28-05-2024 | 300 | 
| 28-05-2024 | 300 | 
| 28-05-2024 | 300 | 
| 28-05-2024 | 300 | 
| 28-05-2024 | 300 | 
| 29-05-2024 | 400 | 
| 29-05-2024 | 400 | 
| 29-05-2024 | 400 | 
| 29-05-2024 | 400 | 
| 29-05-2024 | 400 | 
| 29-05-2024 | 400 | 
| 29-05-2024 | 400 | 
| 30-05-2024 | 500 | 
| 30-05-2024 | 500 | 
| 30-05-2024 | 500 | 
| 30-05-2024 | 500 | 
| 30-05-2024 | 500 | 
| 30-05-2024 | 500 | 
| 30-05-2024 | 500 | 
| 31-05-2024 | 600 | 
| 31-05-2024 | 600 | 
| 31-05-2024 | 600 | 
| 31-05-2024 | 600 | 
| 31-05-2024 | 600 | 
| 31-05-2024 | 600 | 
| 31-05-2024 | 600 | 
| 31-05-2024 | 700 | 
And I need to calculate a cumulative sum for each date as follows -
| Date | Total Sales | 
| 24-05-2024 | 200 | 
| 27-05-2024 | 1000 | 
| 28-05-2024 | 2100 | 
| 29-05-2024 | 2800 | 
| 30-05-2024 | 3500 | 
| 31-05-2024 | 4900 | 
And after calculating the Total Sales, I need to calculate T-1 Total Sales as follows -
| Date | Total Sales | Total Sales T-1 | 
| 24-05-2024 | 200 | |
| 27-05-2024 | 1000 | 200 | 
| 28-05-2024 | 2100 | 1000 | 
| 29-05-2024 | 2800 | 2100 | 
| 30-05-2024 | 3500 | 2800 | 
| 31-05-2024 | 4900 | 3500 | 
Need help to get this sorted. Can someone please help on this?
Solved! Go to Solution.
Hi @SudipRoy1610 ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a table.
Table 2 = SUMMARIZE('Table',[Date],"Total sales",SUM('Table'[Sales]))
(3) We can create a calculated column.
Total sales T-1 = 
var _a=[Date]
var tmp=FILTER('Table 2',[Date]<_a)
var _b=MAXX(tmp,[Date])
return
CALCULATE(MAX([Total sales]),FILTER('Table 2',[Date]=_b))
(4) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
PBI file attached.
Hope this helps.
@SudipRoy1610 Thanks to the new visual calculations it can be very easily done. You can see the the steps below
I am not sure why but when I create the calendar table at my end it is giving me 1st Jan 2024 as the minimum date and 31st Dec 2024 as the maximum date. Even MAX(Date) is giving me 31st Dec 2024, when the answer should be 31st May 2024.
Review my file carefully.
In the image the data contains period from 6th May 2024 to 31st May 2024 from the main table. The data on the left is a calendar created out of the main table just like you mentioned but the earliest date is 1st of Jan 2024 rather than 6th May 2024 and the latest date is 31st Dec 2024 rather than 31st May 2024. This should not happen but not sure what that is the result.
In the Table calculated table formula, remove the .Date
Hi @SudipRoy1610 ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a table.
Table 2 = SUMMARIZE('Table',[Date],"Total sales",SUM('Table'[Sales]))
(3) We can create a calculated column.
Total sales T-1 = 
var _a=[Date]
var tmp=FILTER('Table 2',[Date]<_a)
var _b=MAXX(tmp,[Date])
return
CALCULATE(MAX([Total sales]),FILTER('Table 2',[Date]=_b))
(4) Then the result is as follows.
Best Regards,
Neeko Tang
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.