Forum Discussion
PQ Slowness, parameter and vba
- 8 months ago
Not sure why I can not see my reply here
- 8 months ago
Hi Thamtchou5 ,
Thank you for reaching out to the Microsoft Community Forum.
Please try below things.
1. Power Query should load and merge everything once. Produce one clean, final fact table. Splitting should happen in Excel (PivotTables / formulas) or downstream logic (VBA, Power Pivot, Power BI).
2. Parameters are for environment config (paths, dates, cutoffs), Not for iterating business entities (products, salespeople, regions). If you need 50 outputs --> PQ returns 1 table, not 50 queries.
Please try below target architecture.
Query 1: Static data (OneDrive)
Load once, Clean types, Remove unused columns early and Disable load (staging query).
Query 2 : Folder source (50 files)
Combine files, Promote headers once, Normalize column names, Remove unnecessary columns and Disable load (staging query).
Query 3 : Merge Query 1 + Query 2
Apply all joins once, Apply all business logic once.
Note: Load this query only to Excel Data Model or worksheet. Everything else references this result, not re-runs logic.
Query 4: Instead of 50 filtered PQ queries, You can create ONE master table
and Split downstream.
To split per salesperson try below thing.Load Query 3 to Data Model and Create a PivotTable. Add Salesperson as a filter. Copy PivotTable --> change filter --> export.
Please try below things to increase Power Query performance.
1. Reduce columns BEFORE merge.
2. Avoid repeated references.
3. Merge order: First filter rows and then Merge and Expand only needed columns.
4. Disable load for staging queries, Only one query should load.
Note: “parameter table” should become a normal dimension table and used for filtering downstream, not query execution.
I hope this information helps. Please do let us know if you have any further queries.
Regards,
Dinesh
Thamtchou5 wrote:What do u mean when " filter is done at once " ? Does this allow me to see also result of each filter, copy output to a new sheet, name/save new sheet, and go on following filter
Nein, Du kannst keine einzelnen Filterergebnisse sehen, weil es nur einen Filterschritt für alle Filterwerte gibt. Ich dachte, Du wolltest die 50 einzelnen Filterschritte vermeiden? Wenn Du unterschiedliche Filter verwenden willst, dann müssen die zu filternden Werte entsprechend angepasst werden. Das ginge z. Bsp. über den Einsatz von Pivottables und Slicern. Aber hier kann ich nur spekulieren was Du vorhast...
Thanks again for your time Ralf. Indeed as first stage, I would need to improve structure of my queries, then once I have the right way to merge all data, I need to have a filter and save outputs in different sheets.
Basically, once structure is ok, I need to have a global view of full set of data, and I need to split them and share them with respective salesperson.
For this split, I am thinking at vba, new sheet etc... but o am of course happy to challenge my perspective.
- ralf_anton8 months agoResolver I
Thamtchou5 wrote:Thanks again for your time Ralf. Indeed as first stage, I would need to improve structure of my queries, then once I have the right way to merge all data, I need to have a filter and save outputs in different sheets..
Was ist denn an der Struktur Deiner Abfragen falsch? Das kann ja keiner beurteilen, ohne sie zu kennen. Kannst Du sie hier mal posten?
Thamtchou5 wrote:Basically, once structure is ok, I need to have a global view of full set of data, and I need to split them and share them with respective salesperson.
For this split, I am thinking at vba, new sheet etc... but o am of course happy to challenge my perspective.
Oder meinst Du vielleicht, dass die einzulesenden Dateien unterschiedliche Strukturen haben, die Du vereinheitlichen willst und musst?
Ich denke, ohne Beispiele kommen wir hier nicht weiter.
Zur Aufteilung für die Verkäufer: Ja, da bietet sich VBA an.
Allerdings könntest Du jedem Verkäufer auch ein PQ Template bereitstellen, dass sich die entsprechend gefilterten Daten selbständig aus Deiner #3 zieht.