Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Pbi07
Helper V
Helper V

Cumulative or Rolling total issue

I am trying to do a simple cumulative total using the below measure and having trouble.  The cumulative total is not adding up if i try the DATESMTD or DATESYTD functions. What am i missing 

 

cumulative Total = calculate(sum(Trans[Amount]),DATESYTD('calendar'[Date]))
 
DateSerialAmountcumulative Total
2022-01-1058812001200
2022-01-2072214001400
2022-02-0282025002500
    

 

Expected result is 

 

DateSerialAmountcumulative Total
2022-01-1058812001200
2022-01-2072214002600
2022-02-0282025005100

 

PBix is  https://drive.google.com/file/d/12kfwDvcXWNX3FTWLcOLNBCscRmsGPyoO/view?usp=sharing

 

Thanks

 

1 ACCEPTED SOLUTION

@Pbi07 

Then you have to have an index or ranking column. In other words, for each date-serial combination there must be a unique sort order number column. There a method to do that using dax it is preferable to be done using power query. 

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks @Ashish_Mathur 

The total breaks if i have the serial not in the seqeuntial order. 

I tried ignoring the serial, but then if there are multiple serials for the same day the total repeats. 

Also i modified the total to be the fiscal year total that ends 04/30. 

Attached my pbix - https://drive.google.com/file/d/1qX1zUOhgj_NeSd-IvNaIlBtt6zccJJhT/view?usp=sharing

Pbi07_0-1660932847270.png

 

Trying the fiscal total that ends at 04/30. If i run report upto sept 2021, total will be from May to Sep 2021

 

 

 

davehus
Memorable Member
Memorable Member

Hi @Pbi07 ,

 

Because you have the serial in the table, this is causing the issue with the RT not working for you. Please use the measure below, it should work.

 

davehus_0-1660774358420.png

 

 

cumulative Total = calculate(sum(Trans[Amount]),ALL(Trans),DATESYTD(Trans[Date]))
 
Use the date column from the trans table in the matrix.
 
Did I help you today? Please accept my solution and hit the Kudos button.

Thanks @davehus . Appreciate the help

 

That worked. Only issue is if i have the serials for same day, the cumulative totals repeats. How can it be treated as mor as running totals

 

1400 & 1000 for Jan 20th, results in 3600 repeated for the day

Pbi07_0-1660837197620.png

 

 

tamerj1
Super User
Super User

Hi @Pbi07 
Refer to the sample file attached 

1.png

cumulative Total = 
VAR CurrentDate =
    MAX ( 'calendar'[Date] )
VAR CurrentSerial =
    MAX ( Trans[Serial] )
VAR Result =
    CALCULATE ( 
        SUM ( Trans[Amount] ), 
        'calendar'[Date] <= CurrentDate,
        Trans[Serial] <= CurrentSerial,
        VALUES ( 'calendar'[Year] )
    )
RETURN
    Result

Hi @Pbi07 

have you tried this solution?

@tamerj1 

 

Ran in to the issue when the serails are not in order, meaning if i had a serial with lower # the total comes out wrong.. 

@Pbi07 

Then you have to have an index or ranking column. In other words, for each date-serial combination there must be a unique sort order number column. There a method to do that using dax it is preferable to be done using power query. 

Thanks @tamerj1 . Let me try this out how it behaves with duplicate serials 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.