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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
kkanda
Resolver II
Resolver II

Cumulative total for month

Hi All,

I have run into a problem I cannot resolve. I have set of dates, Target and Actual numbers in a table. I need to calculate the cumulative total for each day of the month. The logic appears to be simple enough, but it doesn't work. Here is the data:

DATE            TARGET ACTUAL RT_mnth st_day_mnth  last_day_mnth

1/1/20232738381/1/20231/31/2023
1/2/20233920201/1/20231/31/2023
1/3/20232637371/1/20231/31/2023
1/4/20233624241/1/20231/31/2023
1/5/20231823231/1/20231/31/2023
1/6/20232319191/1/20231/31/2023
1/7/20231423231/1/20231/31/2023
1/8/20233610101/1/20231/31/2023
1/9/20231440401/1/20231/31/2023
1/10/20231012121/1/20231/31/2023
1/11/20233625251/1/20231/31/2023
1/12/20232020201/1/20231/31/2023
1/13/20231037371/1/20231/31/2023
1/14/20233610101/1/20231/31/2023
1/15/20234029291/1/20231/31/2023

'st_day_mnth' and 'last_day_mnth' are calculate measures from DATE. 'RT_mnth' is the cumulative total of ACTUAL column and has the following expression:

RT_mnth = CALCULATE(
    SUM(TestSh[ACTUAL]), FILTER(TestSh,
        TestSh[DATE]>= [st_day_mnth] && TestSh[DATE] <= [last_day_mnth])
)
I tried ALL and ALLEXCEPT functions but it does not give me the desired result. I have also tried SUMX with the table name and the column ACTUAL, but there is no change. 
Please suggest a suitable change to my code so that I get the cumulative total up to the date in the DATE column for each month. One solution is to change this to a date table and apply DATEMTD. But I want to understand why it is not working. 
Please suggest where I am going wrong. 
 
1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@kkanda 

Use this measure:



RT_mnth =
VAR __StartDate =
    EOMONTH ( MAX ( TestSh[DATE] ), -1 ) + 1
VAR __LastDate =
    MAX ( TestSh[DATE] )
RETURN
    CALCULATE (
        SUM ( TestSh[ACTUAL] ),
        TestSh[DATE] >= __StartDate,
        TestSh[DATE] <= __LastDate
    )
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
kkanda
Resolver II
Resolver II

Thank you @Fowmy... it worked. I tried STARTOFMONTH function for __startDate. That has worked also. 

Fowmy
Super User
Super User

@kkanda 

Use this measure:



RT_mnth =
VAR __StartDate =
    EOMONTH ( MAX ( TestSh[DATE] ), -1 ) + 1
VAR __LastDate =
    MAX ( TestSh[DATE] )
RETURN
    CALCULATE (
        SUM ( TestSh[ACTUAL] ),
        TestSh[DATE] >= __StartDate,
        TestSh[DATE] <= __LastDate
    )
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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