cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Show column names in dropdown

Hi

 

How  can I get a dropdown box to show me the column names as the items

 

So I'm looking for what formula I should use in my Items of the dropdown

 

Something like ShowALLcolumnamaes(Table1)

 

Thanks

 

Jese 

14 REPLIES 14
mdevaney
Super User
Super User

@jesenavaranjan 

Store the contents of Table1 inside a collection.

// collect the table values
ClearCollect(
    colTable1,
    Table1
);

// get the column headers
Set(
    varColumnNames,
    Distinct(
    Ungroup(
        MatchAll(
            JSON(
                colCarInventory,
                JSONFormat.IgnoreBinaryData
            ),
            "([^""]+?)""\s*:"
        ).SubMatches,
        "SubMatches"
    ), Value)
)

 

Then use this code in the Items property of the dropdown to show the column names.

varColumnNames

 

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Worked for me 👍, thanks @mdevaney !

When I use this code, @mdevaney , I get red squiggly lines under colCarInventory. It says it doesn't recognize the name. Should it have the same name as the colTable1 or am I missing something?
@HEATFreight may I ask to see how you managed to get it to work?

@shavora I'm not sure if that's a typo in @mdevaney's code or what, but you need colCarInventory to be an existing collection.

Sounds like you just copied and pasted the code without first editing it for your specific situation.

If you replace colCarInventory in that code with colTable1, or vice versa, and if whichever collection you're using exists and has data stored in it, then the code will produce a list of column headers in varColumnNames. You can't feed it an empty or nonexistent collection.

You are getting the red squiggly line with "unrecognized name" error because you are trying to use a collection name which doesn't yet exist in your app.

@HEATFreight I changed the first one to fit my situation, but for the colCarInventory, I wasn't certain it should refer to an existing one from the description for the provided solution. Hence the question 🙂

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,077)