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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
jansse
Regular Visitor

Comparing col start/ prefix to another tbl and returning corresponding row

Hi, I am fairly new to Power Query but capable of managing my self with basics. Now I received challenge with what I dont have any faintest Idea how to approach it. Could you please help me abit?

 

jansse_1-1733304709870.png

So... I am having col with values and would need to compare the start of this col to another tbl prefix col and if prefix matches returning a new col with description.

1 ACCEPTED SOLUTION

With this I wasnt all the to finish but almoust. This gave me value from the prefix col and not from the description col. I found on another topic thing that i was able to compose as a solution by using your suggested solution

= Table.AddColumn(PREVIOUSSTEP, "prefixFound", each List.First(Table.SelectRows(tblImaginary (insideTbl) => Text.StartsWith([valueToCompare], insideTbl[prefix]))[Description]), type text)

So... in other words I wouldn't have been able to get this with out you!! Thanks you!!!!

View solution in original post

2 REPLIES 2
jgeddes
Super User
Super User

Here is one method to try...
If you have a prefixTable

jgeddes_0-1733326437937.png

and a factTable

jgeddes_1-1733326465841.png

You can add a column to the factTable with the following code...

 

= Table.AddColumn(PREVIOUSSTEP, "prefixFound", each try let rowValue = [valueToCompare] in List.Select(prefixTable[prefix], each Text.StartsWith(rowValue, _)){0} otherwise null, type text)

 

and end up with the result...

jgeddes_2-1733326537399.png

From there you can merge into your prefix table to get the description.

Hope this helps.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





With this I wasnt all the to finish but almoust. This gave me value from the prefix col and not from the description col. I found on another topic thing that i was able to compose as a solution by using your suggested solution

= Table.AddColumn(PREVIOUSSTEP, "prefixFound", each List.First(Table.SelectRows(tblImaginary (insideTbl) => Text.StartsWith([valueToCompare], insideTbl[prefix]))[Description]), type text)

So... in other words I wouldn't have been able to get this with out you!! Thanks you!!!!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.