Hi there, I'm trying to get my head around Power Query...
I have a file with stock quantities per material and another file with sales data for these materials. I have uploaded both files into Power Query and added some columns (e.g. to calculate stock duration in days). I then use the merged data to make some charts and tables, where data can be filtered using slicers. This all works very well.
However, there was an additional request: one table should display which customers a given material was sold to. Of course, there can be more than one customer per material. It seems to me though that PQ will not accept it if I link tables with duplicate values. If I try this, the additional pivot table with material and customers in "rows" and stock value in "values" lists ALL customers for ALL materials, not only the ones where there were actually sales, with identical values for all. And I get an error message when I try to create the relationship between tables.
I was thinking of adding a separate Pivot table to the report (just from the sales data, not using the PQ data), but then this would not be connected to the slicers.
Is there a way I can solve this issue?
Please see attached sample file.
Thanks for any input!
Hi Mirjam,
Great to see you're giving Power Query a go.
If you want to retain the customer detail then what you want is a Power Pivot model, not a merge in Power Query. In order to merge it in Power Query and not have duplicates of the Stock values you'd have to summarise the Sales data, as you've done in your Pivot Sales_Data sheet, but then you lose the detail of the customer orders, which you display on the 'Report' sheet.
In the attached file is the Power Query (Merge1) result of merging the Stock and Sales tables as per your example.
Mynda
Hi Mynda,
Thanks a lot for taking this up! - And for pushing me out of my comfort zone
Ok, so I've tried to set this up in Power Pivot, but I get stuck at the same point as when trying with Power Query - can't seem to get the relationships working properly (due to duplicate values?). I've put together some screenshots in the attached file, hoping you can make sense out of it and point me to where I go wrong.
Appreciating your help!
Mirjam
Hi Mirjam,
You need a dimension table for the Material that you relate your two fact tables (sales & stock) to. The dimension table contains a complete distinct list of the material values.
When you build your PivotTable you use the Material field from the Dimension table, not the Material fields from your fact tables.
Mynda
Phew, now it works!!!
What I did wrong is I wanted to combine stock value with customers in one Pivot Table. Only there is no stock value, just sales value per customer.
Changing this did the trick.
Thanks again for your support!
Mirjam