New Member
July 19, 2024
Hi, I recently used the technique outlined in Phil\'s post here:
VLOOKUP in Power Query Using List Functions • My Online Training Hub
It was really helpful to me, and I have already applied it in a couple of my files.
In Phil's example file the Sales value in the Sales_Data table is looked up in the BonusRates table.
And based on this value, the bonus rate (%) is returned into the Power Query results table (Sales_Bonuses table).
Now, in this example, the field being looked up is "Sales" without any spaces.
However, in my files, I have field names with spaces (e.g. "Income (in USD)" or "Time of Record", etc.).
In such a case, the M Code gives an error because the field name includes spaces.
To replicate this error, I changed the field header from Sales to "Sales Value" in the example file uploaded on the MOTH website.
The error occurs in the M-Code line
= Table.AddColumn(#\"Changed Type\", \"BonusRates\", each let val = [Sales] in List.Select( BonusRates[Threshold] , each _ <= val ))
In this line, the field name "Sales" needs to be "Sales Value".
But I am not able to figure out the correct syntax and get the M Code to work.
I have attached the example file with this change, along with screenshots of the error I'm getting.
Please help!
~KV
Moderators
January 31, 2022
In the Added Custom1 step of the Sales_Bonuses query, just enter the column name as it is between square brackets.
Answers Post
New Member
July 19, 2024
Many thanks @Riny Van Eekelen!
It works perfectly now!
I'm feeling really goofy about this...
Such a simple solution staring me in the face, and it never occurred to me!
Perhaps I was over-thinking about the "spaces in field headings" bit, and never thought of inserting the column name from the Custom Column settings dialog!
1 Guest(s)