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
Anonymous
Not applicable

Running Cumm total by 2 groups

Hello,

I want to calculate running Cumm Total by Region and Month[DATE].  I have attached my Excel and pbix file. I have a ton of records, this just dummy data. The month should be in order like Jan, Feb, March... Can anyone help me with this?

Link for attached file

 

Thank you for your help!

 

sbhan4_0-1597528198130.png

sbhan4_1-1597528235892.png

 

 

2 ACCEPTED SOLUTIONS

@Anonymous 

 

If you are looking for a calculated column, try the below DAX in the calculated field.

 

Running Total column =
SUMX (
    FILTER (
        Sheet1,
        Sheet1[Regions] = EARLIER ( Sheet1[Regions] )
            && YEAR ( Sheet1[Date] ) = YEAR ( EARLIER ( Sheet1[Date] ) )
            && Sheet1[Date] <= EARLIER ( Sheet1[Date] )
    ),
    Sheet1[Actual Target]
)

 

If you are looking for a Measure. Use below DAX

Running Total Measure = TOTALYTD(SUM(Sheet1[Actual Target]),'Date'[Date])

nandukrishnavs_0-1597643759441.png

Refer to the attached pbix file.


Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

View solution in original post

@sbhan4

Use Max de TestCummTotal.

See the attached pbix file in the previous publication.


Regards,
Nandu Krishna

View solution in original post

11 REPLIES 11
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

You can take a look at following measure formula that calculates the cumulative total based on the current group and date if it meets your requirement:

cumulative total =
VAR currDate =
    MAX ( Sheet1[Date] )
RETURN
    CALCULATE (
        SUM ( Sheet1[Actual Target] ),
        FILTER (
            ALLSELECTED ( Sheet1 ),
            YEAR ( [Date] ) = YEAR ( currDate )
                && [Date] <= currDate
        ),
        VALUES ( Sheet1[Regions] )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
lbendlin
Super User
Super User

You need two things - one is a Calendar/Dates table, and then other thing is the cumulative measure.  Luckily the second one is provided to you by Power BI for free - check out the Quick Measures, a collection of ready made formulas. Your scenario is supported.

Anonymous
Not applicable

@lbendlin Thank you for your reply. Could you help me to do that in my power bi workbook which is attached in the post.  

Your Power BI workbook is missing the Calendar/Dates table.  The fact table has very few data rows. Please share a better version.

Anonymous
Not applicable

@lbendlin Thank you for your help!

 

Could you plz try to import my EXcel file in Power BI  (Link attached). It would be great if you can provide me a solution in the workbook. CommTotal column will be output.

 

https://drive.google.com/drive/folders/18zuD7a2rh4pUS5_4LsBGI8zeuS5xqyzF?usp=sharing

Hi @Anonymous ,

 

You can use this measure

 

RT = 

VAR LastVisibleDate =
   MAX ('Table'[Date] )
VAR FirstVisibleDate =
    MIN ( 'Table'[Date])
VAR LastDateofRegions =
CALCULATE(MAX ('Table'[Date] ),ALLEXCEPT('Table','Table'[Regions]))
    
VAR Result =
    IF (
        FirstVisibleDate <= LastDateofRegions,
        CALCULATE (
            SUM('Table'[Actual Target]),
            'Table'[Date]<= LastVisibleDate
        
        )
    )
RETURN
Result

 

 

1.jpg2.JPG

 

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

 

@Anonymous 

 

If you are looking for a calculated column, try the below DAX in the calculated field.

 

Running Total column =
SUMX (
    FILTER (
        Sheet1,
        Sheet1[Regions] = EARLIER ( Sheet1[Regions] )
            && YEAR ( Sheet1[Date] ) = YEAR ( EARLIER ( Sheet1[Date] ) )
            && Sheet1[Date] <= EARLIER ( Sheet1[Date] )
    ),
    Sheet1[Actual Target]
)

 

If you are looking for a Measure. Use below DAX

Running Total Measure = TOTALYTD(SUM(Sheet1[Actual Target]),'Date'[Date])

nandukrishnavs_0-1597643759441.png

Refer to the attached pbix file.


Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

Anonymous
Not applicable

@nandukrishnavs  Your solution is amazing. When I applied to my real data it didn't work properly. I know I missed something and or some data issue. My actual column is count rows...contains 1 1 1 1 as I attached screenshot. I am not able to find where could be my issue. Please help me.

 

sbhan4_0-1597719181525.png

sbhan4_1-1597719297532.png

sbhan4_2-1597719345894.png

 

Anonymous
Not applicable

 

@nandukrishnavs  Hi, I am trying to calculate %  YTD  Target using DIVIDE function. I am not getting the correct output. Did I miss something?

 

 

sbhan4_0-1597970178909.png

 

 

@sbhan4

Use Max de TestCummTotal.

See the attached pbix file in the previous publication.


Regards,
Nandu Krishna

Anonymous
Not applicable

@nandukrishnavs Amazing... it worked. Thank you for your help!

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.