Forum Discussion
Reference a dimension table column in PQE
- 10 months ago
Hi Anonymous ,
In your fact table, try using this code in a new custom column:
Table.SelectRows(Products, (dim) => dim[Product] = [Product])[PrepDays]{0}This will bring in the [PrepDays] value from the dim table against each matching value of Product in the fact table.
Depending on the size of the Products table, you may find that PQ has to scan the table many times to find matches. In this case, you can buffer the Products table to hold it in memory while scanning, avoiding the need for multiple loads:
Table.SelectRows(Table.Buffer(Products), (dim) => dim[Product] = [Product])[PrepDays]{0}Pete
Another option would be to merge the two tables (Table.Join or Table.NestedJoin) using the :Product as the key. Then you could use your original formula on the merged table.
- BA_Pete10 months agoSuper User
Agreed, but OP specifically wants an 'educational' solution:
Pete
- ronrsnfld10 months agoSuper User
- I think both yours and mine are educational in that both are done in power query. Neither is done in DAX. I meant for him to use his power query add column code after merging the tables in power query
- BA_Pete10 months agoSuper User
Ah, I see. When they mentioned 'merging' the dimension onto the fact I assumed in PQ as I think it's a 'join' in DAX, but you could well be right.
Pete