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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
WillBeeSEA
Helper III
Helper III

Reference a dimension table column in PQE

I have a Sales (fact) table with Products and Order Dates.  

I have a Products (dimension) table with PrepDays.

There is a many-to-one relationship between them.

I want to use M Language to create a custom column in the Sales table to calculate the expected Shipping Date by adding the PrepDays to the Order Date.

(I could easily use the RELATED function and do it in DAX, or merge the column from the dimension table into the fact table, but I am trying to force myself to learn more about "M.")

 

I have been able to do it when the PrepTime column is in in the Sales table (where the Order Date is also):

WillBeeSEA_0-1759371756163.png

 

 But when I try to reference the column (PrepDays) the Dimension table, it seems to be searching (the dot dash across the screen repeatedly) but then it times out in 30 seconds:

WillBeeSEA_1-1759371756170.png

 

(I change the column name to avoid confusion between the queries.)

 

As in anything regarding computers, "Everything is simple but nothing is intuitive."

 

Thank you in advance for your help.

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @WillBeeSEA ,

 

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



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

6 REPLIES 6
ronrsnfld
Super User
Super User

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.

 

Agreed, but OP specifically wants an 'educational' solution:

BA_Pete_0-1759407589762.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




  • 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

 

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



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




BA_Pete
Super User
Super User

Hi @WillBeeSEA ,

 

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



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Hi Pete,

Thank you for your input.  I used each of the strings you gave me, but the column still returns errors on each row.  Perhaps my reach has exceeded my grasp at this point in learning M.  I will go back to merging the dimension field into the fact table and using it that way.

Will

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.