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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
sparvez
Helper I
Helper I

Return complete String from multiple columns searched by a susbstring

Hello Altruists,

 

I am in a complex situation trying to solve for last few days, but see no hope. Can anyone pls help me?

 

In a table, i have many columns, column numbers are unknown. Only one cell have the info of "TV".  I need to get the complete string of TV , by using substring "TV" in the newly added column columntoFindxxTV . How to do it pls ?

 

column1---column2---column3---...columnX---columntoFindxxTV
1xTV---1xRadio---2xLaptop---...(null)------1xTV
(null)---3xIpad---2xTV---...(null)---2xTV
1xbook---5xRadio---2xPhone---...5xTV--5xTV

 

thank you in advance.

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Hi @sparvez ,
great! You can rewrite like so:
List.First(List.Select(Record.FieldValues(_), (l)=> Text.Contains(Text.Upper(Text.From(l)), "TV")))

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

4 REPLIES 4
sparvez
Helper I
Helper I

Many thanks @ImkeF 

ImkeF
Community Champion
Community Champion

Hi @sparvez ,
great! You can rewrite like so:
List.First(List.Select(Record.FieldValues(_), (l)=> Text.Contains(Text.Upper(Text.From(l)), "TV")))

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

sparvez
Helper I
Helper I

It works ! thanks so much. Just one small thing, if the substring is abesnt, it needs to return 0 , how can I add it ?

Now, it is showing "Error"  if substring is absent.

ImkeF
Community Champion
Community Champion

Hi @sparvez ,
you add a custom column with this  formula:
List.Select(Record.FieldValues(_), (l)=> Text.Contains(Text.Upper(Text.From(l)), "TV")){0}

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Top Solution Authors