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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Creating dynamic sum subtotal in column function

Hello Power BI comunity, 

 

I'm struggling with creating a dynamic subtotal sum in a custom column. The basic request is to have a subtotal sum which changes when the user applies a filter or slicer. The functionality is known from Excel however, it has not been possible for me to find the function in Power BI.

 

Does anyone have some experience in creating this function?

 

Data sheet (simplified):

ItemsSoldSumSub total
Item 110270270
Item 220270270
Item 330270270
Item 340270270
Item 250270270
Item 115270270
Item 225270270
Item 335270270
Item 145270270

 

Desired outcome (Applied slicer):

ItemsSoldSumSub total
Item 11027070
Item 11527070
Item 14527070

 

Actual outcome (Applied slicer):

ItemsSoldSumSub total
Item 110270270
Item 115270270
Item 145270270

 

Thanks in advance

9 REPLIES 9
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create column like DAX below.

 

Sub total= CALCULATE(SUM(Table1[Sold]),FILTER(ALLSELECTED(Table1), Table1[Items] =EARLIER(Table1[Items])))

Best Regards,

Amy

 

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

Anonymous
Not applicable

Thanks Amy, 

 

However it is still not my desired outcome.

 

The subtotal should be 810 while no slicer is selected, however when a user applies a filter it should create a sum of the seleceted. 

image.png

 

 

 

 

 

 

The regular sum function reduces the number of row however, the value remains static at the 810. My request is that the subtotal becomes 600 in this case where item 2 and 3 is selected. 

image.png

Best regards

Lasse 

 

Where are those numbers coming from for the subtotal in the rows? Item 2, 285?

 

Is this a measure totals problem? If so, Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

No, I used the function given by Amy: 

 

Subtotal = CALCULATE(SUM('Table'[Sold]),FILTER(ALLSELECTED('Table'),'Table'[Items]=EARLIER('Table'[Items])))
 
This what the data column looks like. 
image.png

The 285 is basically the sum of item 2 times 3 becasue it occurs three times.   

Hi @Anonymous ,

 

When I use the formula above, the Subtotal will return the result 600 instead of 800. I am not sure what desired result would you want, could you please show your desired output screenshots for further analysis?

 

58.png

 

 

 

 

Best Regards,

Amy

 

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 Amy, 

 

This is my desired outcome:

When i filter to see 'Item 2' and 'Item 3' then i summerize in a subtotal. 

image.png

 

 

 

 

Or 'Item 1' and 'Item 3'. 

image.png

 

 

 

 

 

 

 

It is used to achive a dynamic sum the items should be divided with in the end. 

 

Do you understand my desired outcome?

 

Best regads

Lasse 

 

 

 

 

 

Anonymous
Not applicable

Has anyone found a solution yet?

Greg_Deckler
Community Champion
Community Champion

Seems like you want something like this measure:

 

Measure = 
var __item = MAX([Items])
var __table = FILTER(ALL('Table'),[Items] = __item)
RETURN
SUMX(__table,[Sold])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks for your answer

 

Me issue is though I want to build it into a custom column, since i want to divide every single row/value with the 'total sum'.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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