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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Matej
Helper I
Helper I

Cumulative value for each month

Hey guys, 

I'm trying to create a measure that would return cumualtive value for each month - starting on first with 0.00 and adding sum of sales amounts every day up to the last day of the month. 

 

So far I have created a measure that returns cumulative for all of the time my dataset is related to:

 

TESTCumulative2 =
CALCULATE(
[TESTSalesOrder],
FILTER(
ALL('Transaction Date'),
'Transaction Date'[*Date (trans)] <= MAX('Transaction Date'[*Date (trans)])
)
)

 

 Matej_0-1687966028381.png


Can anyone please advise how to proceed to get only a current month values? Also, my date table goes up to 31/12/2023 (as clearly visible on the top of the graph) - would that cause a problem when measure is specified for each month? 

Any recommendations/advices would be much appreaciated. 

1 ACCEPTED SOLUTION

Hi @Matej,

The best practice would be to create a calendar table and let your users choose which month they'd like to see. If you want only the last month from your dataset and don't want new tables whatsoever, you could modify the measure like this:

barritown_0-1688044846004.png

And in plain text:

Measure = 
VAR MaxDate = MAXX ( ALL ( data ), [Date] )
VAR CurrentDate = MAX ( [Date] )
VAR CurrentMonth = MONTH ( MaxDate )
VAR CurrentYear = YEAR ( MaxDate )
VAR Res = SUMX ( FILTER ( ALL ( data ), [Date] >= DATE ( CurrentYear, CurrentMonth, 1) && [Date] <= CurrentDate ), [Value] )
RETURN IF ( FORMAT ( CurrentDate, "YYYYMM" ) = FORMAT ( MaxDate, "YYYYMM" ), Res, BLANK () )

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

View solution in original post

6 REPLIES 6
Matej
Helper I
Helper I

Hi @barritown,

I have created a measure couple month ago based on your advices:

_timeIntelMonthSALES =
VAR CurrentDay = TODAY()
VAR MaxDate = MAX('Transaction Date'[*Date (trans)])
VAR CurrentMonth = MONTH(CurrentDay)
VAR CurrentYear = YEAR(CurrentDay)
VAR FirstDay = DATE(CurrentYear, CurrentMonth, 1)
VAR SO = IF(TODAY() = DATESBETWEEN('Transaction Date'[*Date (trans)], FirstDay, CurrentDay), [_Revenue £], 0)
VAR Res = SUMX(
FILTER(
ALL('Transaction Date'),
'Transaction Date'[*Date (trans)] >= DATE(CurrentYear, CurrentMonth, 1)
&& 'Transaction Date'[*Date (trans)] <= MaxDate
&& 'Transaction Date'[*Date (trans)] <= CurrentDay
),
[_Revenue £]
)
RETURN
IF(FORMAT(MaxDate, "YYYYMM" ) = FORMAT(CurrentDay, "YYYYMM"), Res, BLANK())

I am now trying to get this to return previous month with cumulative [_revenue]. So far, I have managed to get the time intelligence to return previous month but I always lose the cumulative measure while doing it - I always end up with just the total for whole month, it is not spread by days.
Would you be please able to help me to modify this measure to return previous month but still retain the cumulative way of doing it? Basically what I am trying to achieve is comparison of this cumulative month vs previous cumulative month (but I keep just bangign my head agains the wall at the moment).

Hi @Matej,

 

I wonder if you can create a PBIX file with some mocking data similar to your original dataset, incorporate your measure in it and share the file with me?

 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

barritown
Super User
Super User

Hi @Matej,

I guess you need something like this:

barritown_0-1688024685072.png

In plain text for convenience:

Measure = 
VAR CurrentDate = MAX ( [Date] )
VAR CurrentMonth = MONTH ( CurrentDate )
VAR CurrentYear = YEAR ( CurrentDate )
RETURN SUMX ( FILTER ( ALL ( data ), [Date] >= DATE ( CurrentYear, CurrentMonth, 1) && [Date] <= CurrentDate ), [Value] )

 Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

Hi @barritown 

Thanks a lot for you time and help, realy appreciate it. 
The measure works as intended. Do you know if there is a way of adjusting the measure so when placed in the visual it only displays current month? I would realy like to avoid a situation when the visual is operated by the slicer which would have to be moved manually by one day every day (and to the beging of the month when month starts). 

Many thanks

Hi @Matej,

The best practice would be to create a calendar table and let your users choose which month they'd like to see. If you want only the last month from your dataset and don't want new tables whatsoever, you could modify the measure like this:

barritown_0-1688044846004.png

And in plain text:

Measure = 
VAR MaxDate = MAXX ( ALL ( data ), [Date] )
VAR CurrentDate = MAX ( [Date] )
VAR CurrentMonth = MONTH ( MaxDate )
VAR CurrentYear = YEAR ( MaxDate )
VAR Res = SUMX ( FILTER ( ALL ( data ), [Date] >= DATE ( CurrentYear, CurrentMonth, 1) && [Date] <= CurrentDate ), [Value] )
RETURN IF ( FORMAT ( CurrentDate, "YYYYMM" ) = FORMAT ( MaxDate, "YYYYMM" ), Res, BLANK () )

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

This works perfectly, thanks a lot for your time and help!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.