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
ronaldbalza2023
Continued Contributor
Continued Contributor

Running Total by month

Hi everyone, how can I have a measure that is running total? I have a date table and visual that has a slicer of month and year.

The problem with my measure is that when I have ticked the slicer into the current month (say October), this gives me the amount on October only and does not count the previous month.

 

Table:

ronaldbalza2023_2-1639010837123.png

Measure:

Running Total = 
CALCULATE( 
	[Total Sales], 
	FILTER(
		ALLSELECTED( 'Date'),
		'Date'[Date] <= MAX( 'Date'[Date])
	)
)

 

Slicer:

ronaldbalza2023_1-1639010797097.png

 

 

 

1 ACCEPTED SOLUTION

Hi, 

Sorry that only seeing the picture does not help me to write the accurate measure.

Please try to add the condition that shows the same year with the slicer selection.

 

For instance,

Running Total =

CALCULATE( [Total Sales],

FILTER( ALL( 'Date'),  yearcolumn = max(yearcolumn) &&  'Date'[Date] <= MAX( 'Date'[Date]) ) )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

6 REPLIES 6
Jihwan_Kim
Super User
Super User

Hi,

Instead of using ALLSELECTED, please try to use ALL and more conditions adding into the CALCULATE that are only calculating for the same year + less than or equal to the current date.

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Hi @Jihwan_Kim , thanks for taking the time on this. I use the ALL instead of ALLSELECTED and it gave me a weird total. I also removed the filter slicer selection.

ronaldbalza2023_0-1639025364345.png

Running Total = 
CALCULATE( 
	[Total Sales], 
	FILTER(
		ALL( 'Date'),
		'Date'[Date] <= MAX( 'Date'[Date])
	)
)

 

ronaldbalza2023_1-1639025416535.png

 

Hi, 

Sorry that only seeing the picture does not help me to write the accurate measure.

Please try to add the condition that shows the same year with the slicer selection.

 

For instance,

Running Total =

CALCULATE( [Total Sales],

FILTER( ALL( 'Date'),  yearcolumn = max(yearcolumn) &&  'Date'[Date] <= MAX( 'Date'[Date]) ) )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


@Jihwan_Kim kamsahamnida Kim! Works like a charm 🙂

amitchandak
Super User
Super User

@ronaldbalza2023 , fi you select one month and want more than one month then you need an independent table

 

else this should work

 

Running Total = 
CALCULATE( 
	[Total Sales], 
	FILTER(
		ALL( 'Date'),
		'Date'[Date] <= MAX( 'Date'[Date])
	)
)

 

also refer

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Hi @amitchandak, thanks for taking the time on this. On your video link, I haven't done your suggestion yet with having two dates table. What I've done is I copied your datesinperiod dax and played it a little bit. However, it is not dynamic as it should be. The current slicer is for October which is showing the correct running total, however when I changed it to another month say September, it will not show the correct total. I think having two dates table is not a good idea.

Running Total = 
CALCULATE (
    [Total Sales)],
    DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -4, MONTH )
)

 

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.