PentaGalCXO
New Member
- Joined
- Jan 31, 2012
- Messages
- 46
I need help with Power Query M code. Assume I have a list of customers with [CustNum] as key (via query "qryCustomerList"). I would now like to add a column "SalesTable" where the field contains a table of Sales data relative to that customer (via query "qrySales"). Note that qrySales has field [SoldToNum] which ties to [CustNum], and several other fields I will need later in the query. Here is a simplified version of my query:
Let
Source = qryCustomerList,
AddSalesTable = Table.AddColumn(Source,"SalesTable", each Table.SelectRows(qrySalesData, each [SoldToNum] = [CustNum])),
The problem is PQ doesn't recognize [CustNum] in this context. It expects [CustNum] to be a field in qrySales. I need it to reference the value of [CustNum] for the current row of Source. Note that if I replace [CustNum] with a static value such as "1234" the query will run and I get a table of 1234's Sales data for each customer in Source. So I feel like I'm close. In the DAX world I think this would be a case for Earlier(), but I can't find the 'M' equivalent.
Help!
Let
Source = qryCustomerList,
AddSalesTable = Table.AddColumn(Source,"SalesTable", each Table.SelectRows(qrySalesData, each [SoldToNum] = [CustNum])),
The problem is PQ doesn't recognize [CustNum] in this context. It expects [CustNum] to be a field in qrySales. I need it to reference the value of [CustNum] for the current row of Source. Note that if I replace [CustNum] with a static value such as "1234" the query will run and I get a table of 1234's Sales data for each customer in Source. So I feel like I'm close. In the DAX world I think this would be a case for Earlier(), but I can't find the 'M' equivalent.
Help!