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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
TapZxK
Helper II
Helper II

cumulative monthly total

Hi Folks, 

 

I have written a measure that calculates cumulative monthly totals.

 

Total Rolling Expenses =
CALCULATE ( [Total Historical Expenses], DATESYTD ( 'Calendar'[Date], "8/31" ) )

 

Everything appears ok but i'm getting numbers for the future dates.

Any ideas how to remove values for the months that do not have the data yet. 

 

In the example below the data is available until month of January (Including) but as you can see the line extends until end of year with the same values as the values in January. 

 

TapZxK_0-1644919078086.png

 

BR,

TapZxK

 

1 ACCEPTED SOLUTION

Hi, @TapZxK 

You need to check if the parentheses match. The measure should be changed as:

 

Total Rolling Expenses =
IF (
    MAX ( 'Calendar'[Date] ) <= TODAY (),
    CALCULATE ( [Total Historical Expenses], DATESYTD ( 'Calendar'[Date], "8/31" ) ),
    BLANK ()
)

 

 

You can also create a measure as below and apply it to visual filter pane to filter data.

 

filter =
IF ( MAX ( 'Calendar'[Date] ) <= TODAY (), 1, 0 )

 

2.png

Best Regards,
Community Support Team _ Eason

View solution in original post

4 REPLIES 4
Meeskass
Helper I
Helper I

Hi, cool solution, but then the yearly total shows Blank() as well. Any idea how to still include the totals when using the IF function?

amitchandak
Super User
Super User

@TapZxK , You can have measures like

 


Total Rolling Expenses =
CALCULATE ( [Total Historical Expenses], DATESYTD ( 'Calendar'[Date], "8/31" ), 'Calendar'[Date]<=today() )

 

 or

 

Total Rolling Expenses =
if(max('Calendar'[Date]<=today()), CALCULATE ( [Total Historical Expenses], DATESYTD ( 'Calendar'[Date], "8/31" ), blank())

 

or in place of today use this from you fact Table

var _today = maxx(allselected(Fact), Fact[Date])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak


Thanks for your prompt reply as always. 
I tried what You suggested. Unfortunately, it didn't work.

I'm still getting the same results. See Screenshots below. 

There are active 1 - To - Many relationships between Calendate[Date] -> Expenses[Date] Tables. 

 

TapZxK_0-1644933659008.png

 

When trying the below measure I'm getting an error, not sure why though. 

 

Total Rolling Expenses =
if(max('Calendar'[Date]<=today()), CALCULATE ( [Total Historical Expenses], DATESYTD ( 'Calendar'[Date], "8/31" ), blank())

TapZxK_1-1644933732276.png

 

Best Regards,

TapZxK

Hi, @TapZxK 

You need to check if the parentheses match. The measure should be changed as:

 

Total Rolling Expenses =
IF (
    MAX ( 'Calendar'[Date] ) <= TODAY (),
    CALCULATE ( [Total Historical Expenses], DATESYTD ( 'Calendar'[Date], "8/31" ) ),
    BLANK ()
)

 

 

You can also create a measure as below and apply it to visual filter pane to filter data.

 

filter =
IF ( MAX ( 'Calendar'[Date] ) <= TODAY (), 1, 0 )

 

2.png

Best Regards,
Community Support Team _ Eason

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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