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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

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 carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.