web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Get Specfic column nam...
Power Apps
Answered

Get Specfic column names from collection

(0) ShareShare
ReportReport
Posted on by 361

I have a collection like following,

 

Column1Column2Column3
Value1""""

 

I want to retrieve the specific column names from the collection.

For Eg: I want to filter the column with empty values and it should return the column names in the collection 

or need to build a collection with column names that have empty rows.

 

For Eg:

Data

Column2

Column3

 

Categories:
I have the same question (0)
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @hemrhk 

    Per Matt Deveney:

     Set(
     myJSON,
     Distinct(
     Ungroup(
     MatchAll(
     JSON(
     mycollection,
     JSONFormat.IgnoreBinaryData
     ),
     "([^""]+?)""\s*:"
     ).SubMatches,
     "SubMatches"
     ),
     Value
     )
     )

     

  • Verified answer
    rubin_boer Profile Picture
    4,843 Super User 2024 Season 1 on at

    hi @hemrhk as per @Drrickryp this code from Matt will give you the column names. you may want to add to the code the following:

     

    Assumptions; here we have three columns called col1, col2, col3

    Create a new collection colAll (or as you wish) and have it count the number of nulls or empty strings in it. the Switch statement will run the filter on the desired column (i am not aware if this can be done dynamically yet)

     

    ClearCollect(
     colAll,
     AddColumns(
     colHeaders,
     "Have Nulls",
     CountRows(
     Filter(
     colGetNullColumns,
     Switch(
     true,
     Result = "col1",
     col1 = "",
     Result = "col2",
     col2 = "",
     Result = "col3",
     col3 = ""
     )
     )
     )
     )
    )

     

     

    now that you have colAll to get all the columns which have empty strings or null is another filter

     

    Filter(
     colAll,
     'Have Nulls' > 0
    )

     

     

    Result:

    The original collection

    rubin_boer_0-1655659060413.png

     

    The column names in a column (Matts code)

    rubin_boer_1-1655659088446.png

     

    Add the number of nulls/empty strings

    rubin_boer_2-1655659125542.png

     

    apply final filter to visualise only column with empty string

    rubin_boer_3-1655659153980.png

     

    Hope it helps,

    R

    Ps colHeaders is the implementation to get the column names

    Collect(
     colHeaders,
     Distinct(
     Ungroup(
     MatchAll(
     JSON(
     colGetNullColumns,
     JSONFormat.IgnoreBinaryData 
     ),
     "([^""]+?)""\s*:"
     ).SubMatches,
     "SubMatches"
     ),
     Value
     )
     );

     

     

     

     

  • hemrhk Profile Picture
    361 on at

    Thanks @Drrickryp . 

     

    I have already tried this one.

  • hemrhk Profile Picture
    361 on at

    Thanks @rubin_boer 

     

    It is working as expected, This approach did not strike previously. Thanks again for helping out !!!

  • subsguts Profile Picture
    1,259 Moderator on at

    FYI, this code doesn't work I tried to use it and it gives me errors of incompatible types, etc. and that I'm using the variable somewhere else in my code, etc.  which isn't true.  So, I think this got broke in the last few years would love an update.

  • CA-24100924-0 Profile Picture
    2 on at
    @subsguts Removing some of the Quotes works for me in 2025. However, this solution doesn't allow me to select specific columns. In my use case, I want to select some specific columns that are sortable. I'd like some auto complete like i would get for ShowColumns
     
    Distinct(
            Ungroup(
                MatchAll(
                    JSON(
                        colTable,
                        JSONFormat.IgnoreBinaryData
                    ),
                    "([^""]+?)""\s*:"
                ).SubMatches,
                SubMatches
            ),
            Value
        )
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard