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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Dayna
Helper V
Helper V

Sub total issue with sum containing duplicate values

Hello,

 

I have a simple value which is Quantity, I have added this to a table and using the standard PowerBI function it is doing a sum - this is just a field, not a measure and no calculation applied.


This quantity field is is quantity for a component. My table shows products which may have the same component, i.e.

 

Product     Component     Quantity

ProductX   Comp1             10 

ProductY   Comp2             15

ProductZ   Comp1             10

 

For the above, the quantity sub total should be 25, as it's the sum of the quantity values for each unique component, but currently it is bring back 35 as it's summing every row.

 

I suspect rather than adding the quantity field, I need to wrap it in a calculation, but what do I need to do to make the sub total then only sum the distinct component values on the table?

 

Many thanks,

Dayna

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Dayna ,

 

I believe you are referring to the totals circled in the screenshot below.

vstephenmsft_1-1644561928961.png

 

Here's the solution. You can create a measure.

Measure  = VAR _t=DISTINCT(SELECTCOLUMNS('Table',"C",[Component],"Q",[Quantity]))
RETURN SUMX(_t,[Q])

vstephenmsft_2-1644562356138.png

 

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
Anonymous
Not applicable

Hi @Dayna ,

 

I believe you are referring to the totals circled in the screenshot below.

vstephenmsft_1-1644561928961.png

 

Here's the solution. You can create a measure.

Measure  = VAR _t=DISTINCT(SELECTCOLUMNS('Table',"C",[Component],"Q",[Quantity]))
RETURN SUMX(_t,[Q])

vstephenmsft_2-1644562356138.png

 

Best Regards,

Stephen Tao

 

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

 

Tahreem24
Super User
Super User

@Dayna You need to create a measure like below:

MEASURE = CALCULATE(SUM(Table[Quantity]),ALLEXCEPT(Table,Table[Component]))

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Hello,

 

I did that but the numbers were exactly the same as without the measure, but perhaps I've not used the right component in the latter part - I used the one on the table with the value, rather than the one used in the table. If I did that, then it showed a lot of components that it should do in the grid!

 

Can you assist?

 

Thanks,

Dayna

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors