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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Captainarw
Frequent Visitor

LOOKUPVALUE in M

Hi

 

I have this code in M when trying to add a new column with a LOOKUP, which is constantly saying "Token Comma Expected":

 

#"Added Conditional Column1" = Table.AddColumn(#"Changed Type4", "Custom", each if Text.StartsWith([Loss Location Postcode Abbrev], "1") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "2") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "3") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "4") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "5") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "6") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "7") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "8") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "9") then "USA- In Transit" else LOOKUPVALUE(#"Canadian Postal Codes"[Place Name],#"Canadian Postal Codes"[Postal Code],#"Claims"[Loss Location Postcode Abbrev])

 

Can anyone kindly assist please??

 

Many thanks

5 REPLIES 5
AlB
Super User
Super User

@Captainarw 

Table.SelectRows(#"Canadian Postal Codes", (inner)=>inner[Postal Code] = [Loss Location Postcode Abbrev])[Place Name]{0}

If this does not work I'd need the pbix (with dummy data if necessary, reproducing the issue) to come up with an accurate solution

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

Captainarw
Frequent Visitor

Hi Thanks for your reply. Apologies, I am new to Power BI. When I add that in I get this:

#"Added Conditional Column1" = Table.AddColumn(#"Changed Type4", "Custom", each if Text.StartsWith([Loss Location Postcode Abbrev], "1") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "2") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "3") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "4") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "5") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "6") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "7") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "8") then "USA- In Transit" else if Text.StartsWith([Loss Location Postcode Abbrev], "9") then "USA- In Transit" else Text.SelectRows(#"Canadian Postal Codes", (inner)=>inner[Postal Code] = [Loss Location Postcode Abbrev])[Place Name]{0})

 

Now I am getting an error message "Expression.Error: The name 'Text.SelectRows' wasn't recognized. Make sure it's spelled correctly". Could you kindly offer some support?

 

Thank you.

 

AlB
Super User
Super User

Hi @Captainarw 

LOOKUPVALUE is not M, it is DAX. Try

Instead of

 

LOOKUPVALUE(#"Canadian Postal Codes"[Place Name],#"Canadian Postal Codes"[Postal Code],#"Claims"[Loss Location Postcode Abbrev])

 

try

 

Table.SelectRows(#"Canadian Postal Codes", (inner)=>inner[Postal Code] = [Loss Location Postcode Abbrev])[Place Name]{0}

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

Hi, sorry I tried this and it didn't work see asbove. Am I missing something? Just to confirm the end result is the [Place Name] in the table "Candian Postal Codes" and I am performing the funtion on the table "Premium", thanks..... 

Sorry amend above, the function is on the table "Claims" not "Premium" and the field in the claims table is called "Loss Postcode Abbrev" 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.