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
Anonymous
Not applicable

Running Total by Group - Matrix Total

I am having issues with calculating a running total by group (sex) in a matrix. My table is an attendance sheet so I just need to calculate the running total of the number of rows (attendants) for each year. I made a calculated measure and it worked fine for the column chart. Here is the code and the chart:

Running Total by Sex = 
CALCULATE(
	COUNTROWS('tbl1'),
	FILTER(
		ALL('tbl1'),
		'tbl1'[Date] <= MAX('tbl1'[Date]) &&
		'tbl1'[Sex] = MAX('tbl1'[Sex])
	)
)

Annotation1.png

But when I converted it to a matrix, the total doesn't seem to add up properly. I put [Sex] as rows, [Date] (hierarchy) as columns and the Running Total by Sex measure as the Values. What am I doing wrong?

 

Annotation2.png

Thanks in advance...

 

 

 

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

@Anonymous ,

Sorry, try this

Running Total by Sex = 
CALCULATE(
	COUNTROWS('tbl1'),
	FILTER(
		ALLEXCEPT('tbl1', 'tbl1'[Sex]),
		'tbl1'[Date] <= MAX('tbl1'[Date]) 
	)
)

Regards,
Mariusz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

Try the below.

 

Running Total by Sex = 
CALCULATE(
	COUNTROWS('tbl1'),
	FILTER(
		ALLEXCEPT('tbl1', 'tbl1'[Sex]),
		'tbl1'[Date] <= MAX('tbl1'[Date]) &&
	)
)


Regards,
Mariusz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @Mariusz ,

 

That worked!  Thanks!  

Running Total by Sex = 
CALCULATE(
	COUNTROWS('tbl1'),
	FILTER(
		ALLEXCEPT('tbl1', 'tbl1'[Sex]),
		'tbl1'[Date] <= MAX('tbl1'[Date])
	)
)

@CheenuSing : Thanks for your help.  Problem solved...

 

 

 

 

Mariusz
Community Champion
Community Champion

@Anonymous ,

Sorry, try this

Running Total by Sex = 
CALCULATE(
	COUNTROWS('tbl1'),
	FILTER(
		ALLEXCEPT('tbl1', 'tbl1'[Sex]),
		'tbl1'[Date] <= MAX('tbl1'[Date]) 
	)
)

Regards,
Mariusz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

CheenuSing
Community Champion
Community Champion

Hi @Anonymous 

 

Just create the measure

 

RunningTotal = COUNTROWS('tbl1')

 

Try it out and let me know.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!
Anonymous
Not applicable

Hi @CheenuSing ,

 

Thanks but it didn't work Smiley Sad.  I get just a regular total instead of a running total now...

 

Annotation3.png

 

 

 

Hi @Anonymous ,

 

Can you share the pbix in Google Drive or OneDrive and paste the link here to check and suggest.

 

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!
Anonymous
Not applicable

Hi @CheenuSing ,

 

Sure.  I can't seem to share outside of my organization so give me a moment to figure out how to share this externally...

 

 

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.