Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Query
Answered

List Column Headers Of Columns In Which Text String Appears

(0) ShareShare
ReportReport
Posted on by 6

Hi all, CGPT and Bing AI weren't helping, so I want to see if this sub can help.

So, I have the following table in Power Query:

 

| column1 | column2 | column3 |
| ------- | ------- | ------- |
| apple juice | pear | orange |
| apple | fig | apple cider |
| apple pie | apple | apple jam |

, where the number of columns is dynamic and new columns might be added later.

How do I add a custom column showing the column headers in which the word "apple" (case-insensitive) appears in each row. For e.g., if "apple" shows up in columns 1 and 2 of row 1, corresponding cell in the custom column would be "column1, column2". If "apple" shows up in cols 1,3 and 4 of row 2, corresponding cell in custom column would be "column1, column3, column4" etc.. Please help?

  • seedrs91 Profile Picture
    6 on at
    Re: List Column Headers Of Columns In Which Text String Appears

    Thank you for the explanation! This has been very helpful!

  • seedrs91 Profile Picture
    6 on at
    Re: List Column Headers Of Columns In Which Text String Appears

    Sorry wdx223_Daniel, I'm tried breaking down your one-step formula into different steps to make myself learn better but I got a column of all error values when trying to Text.Combine() the [Name] column in the query titled Table1 (2). Do you mind if I send you the workbook for you to check what I did wrong?

  • seedrs91 Profile Picture
    6 on at
    Re: List Column Headers Of Columns In Which Text String Appears

    Hi Syndicate_Admin,

     

    Thanks for your help! As I'm very new to M code, may I ask why we don't convert the table to records first before turning the records to a table? Sorry, I'm having a hard time understanding how Table.SelectRows(Record.ToTable(_) works when there are no records in the previous step. The rest of your code, I understand.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Query

#1
mmbr1606 Profile Picture

mmbr1606 9 Super User 2025 Season 1

#2
SD-13050734-0 Profile Picture

SD-13050734-0 6

#3
Jon Unzueta Profile Picture

Jon Unzueta 2

Overall leaderboard

Featured topics