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
OSS
Helper III
Helper III

Appended queries optimization

Dear all

I have 12 sales tables. (Sales by monthes)

Columns are: customer id, product id and amount.

 

I append all 12 tables (queries) and get final result with more than 5 million rows. Could you please help me to pivot all of this data. I would like to sum amounts for the same customer id and product id.

13 REPLIES 13
Greg_Deckler
Community Champion
Community Champion

Are you saying that you want to pre-aggregate the data in Power Query before importing into your data model? Right click customer id in the Query Editor and choose Group By and then choose Advanced to group by two or more columns.



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...

Dear Greg. Thank you for response.

 

I have 12 separate queries (12 excel uploads). I have appended them and get 1 one Yearly sales table with 12 amount columns. Then I have created new 'Grand Total' column and add up all these 12 monthes sales. Now I want to pivot my results related to this new 'Grand Total' column. Your solutions is good, but it works for native query columns. The columns which are added out of query editor will not be found in query ediyor window.

tex628
Community Champion
Community Champion

Add a date column to each query with the appropriate month and make sure that the other columns all have the same name ( Amount, Product, Customer). Then append the 12 queries and you should be able to show the values by dimension.


Connect on LinkedIn

Actually I don't need any date for my queries. Before uploading I correct all my tables and make all columns the same name.

Greg_Deckler
Community Champion
Community Champion

Perhaps this DAX Unpivot Quick Measure:

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/DAX-Unpivot/m-p/574832

 

If not, please provide very simple sample/example data and expected result. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



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...

Since my queries contain huge amount of data I try to create sample of the data in the excel.

I wonder, if merge function will be solution for me?

 

Capture.PNG

tex628
Community Champion
Community Champion

If you append with the names being the same this should be the result: 

image.png

From here you can easily show total amount per customer or product.


Connect on LinkedIn

Your are right tex628.

This is exactly what I have now. But I want to see 31+10+19=60 for 202 Customer.

If product id and customer id are the same I would like to sum the amount. 

tex628
Community Champion
Community Champion

If you create a matrix and then use your columns like this:

image.png

Aren't you getting 60 for customer 202?


Connect on LinkedIn

In matrix view everything is ok. But, after appending I have 5 million rows. I want to merge these rows, sum amounts and get less row amount. Is it possible to group, or pivot, or merge my data on data level, not report level?

tex628
Community Champion
Community Champion

Try this: 

Left click on a column in power query and choose group by. 

Use these settings:

image.png


Connect on LinkedIn

This is also doesn't work 😞  We have already discussed this issue in the previous message

@OSS,

 

You may also try SUMMARIZE and GROUPBY in DAX.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.