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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Knoen
New Member

Need help with a sum

Hey Guys

 

Im trying to use Power Query and excel to get a sum of a colum right. This is how it looks now. As you can se there are blank rows between the groups.

 

DescArticle numberSizeSoldBoughtOver/Under
Description Axxxsan110-1
Description Axxxsan220-2
Description Axxxsan320-2
Description Axxxsan430-3
Description Axxxsan530-3
Description Axxxsan630-3
Description Axxxsan730-3
Description Axxxsan810-1
Description Axxxsan910-1
Description Axxxsan1010-1
      
      
Description Bxx1out110-1
Description Bxx1out210-1
Description Bxx1out350-5
Description Bxx1out420-2
Description Bxx1out520-2
Description Bxx1out620-2
Description Bxx1out710-1
      
      
Description Cxx2out1220
Description Cxx2out2220
Description Cxx2out3220
Description Cxx2out4220
Description Cxx2out5121
Description Cxx2out6110
Description Cxx2out7110
Description Cxx2out810-1
      

 

I would like to sum the sold and bought columns of each group so it looks like this:

 

DescArticle numberSizeSoldBoughtOver/Under
Description Axxxsan110-1
Description Axxxsan220-2
Description Axxxsan320-2
Description Axxxsan430-3
Description Axxxsan530-3
Description Axxxsan630-3
Description Axxxsan730-3
Description Axxxsan810-1
Description Axxxsan910-1
Description Axxxsan1010-1
   SUM()SUM() 
      
Description Bxx1out110-1
Description Bxx1out210-1
Description Bxx1out350-5
Description Bxx1out420-2
Description Bxx1out520-2
Description Bxx1out620-2
Description Bxx1out710-1
   SUM()SUM() 
      
Description Cxx2out1220
Description Cxx2out2220
Description Cxx2out3220
Description Cxx2out4220
Description Cxx2out5121
Description Cxx2out6110
Description Cxx2out7110
Description Cxx2out810-1
   SUM()SUM() 

 

How can i do this? My code looks like this:

 

 

1 REPLY 1
PhilipTreacy
Super User
Super User

Hi @Knoen 

 

You want to do this inside PQ in a single table before outputting to Excel?  Whilst this could be done, I would advise against it.  PQ should be used to format data into a tabular layout that does not include totals.  One you insert totals into this data, it'll become a nightmare to work with if you want to do anything else.

 

Calculating things like totals should be done later in the Excel sheet or in PBI using DAX and/or visuals.

 

Try separate queries for each group and load each of these into separate tables in Excel, or load to the Data Model for use with Power Pivot.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors