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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

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
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors