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 / Choose Columns from a ...
Power Apps
Unanswered

Choose Columns from a drop down selected value

(1) ShareShare
ReportReport
Posted on by 23

Hi All,

 

NewSpList is my SharePoint list and it has more than 30 columns

 

I have to Show 3 Columns in Gallery.

1st and 2nd column are static. 3rd Column will be chosen from a dropdown.

 

In ShowColumns I am not able to add the dropdown selected value as a column name.

 
ShowColumns(
   NewSpList,
    Title,
    EmpStatus,
    SubCategory.Selectedtext.Value
)
 
I tried both SubCategory.Selected.Value.
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    154,889 Most Valuable Professional on at

    Hi @sivarajan6065 ,

    You cannot refer to a column names dynamically, so you cannot do what you want with that structure. As well as ShowColumns needing the actual column hard-coded, having conditional output for a Gallery generally does not work. Something like this (using your column names) should work

    ShowColumns(
     AddColumns(
     NewSpList,
     NewCol,
     Switch(
     SubCategory.Selected.Value,
     "Column1",
     Column1,
     "Column2",
     Column2,
     "Column3",
     Column3,
     "Column4",
     Column4
     )
     ),
     NewSpList,
     EmpStatus,
     NewCol
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • luisveltze Profile Picture
    13 on at

    The ShowColumns function includes columns of a table and drops all other columns. If you have a dropdown with the column names, you can set the OnChange property to update a context variable that contains the columns you want. You can then pass this context variable to your gallery.

     

    OnChange property:

     

     

    Switch(
     Self.Selected.Value,
     "SubCategory1",
     UpdateContext({ColumnsToDisplay : ShowColumns(NewSpList, Title, EmpStatus, SubCategory1)}),
     "SubCategory2",
     UpdateContext({ColumnsToDisplay : ShowColumns(NewSpList, Title, EmpStatus, SubCategory2)})
    )

     

     

    Gallery Items property:

    ColumnsToDisplay

    If my post helped resolve your issue, please click "Accept as solution."

     

    PowerApps.gif
  • sivarajan6065 Profile Picture
    23 on at

    Hi @WarrenBelz ,

    I have tried yours and it works fine. I have added the columns to collection and added to gallery items.

     

    Clear(DisplayColumns);

    Collect(
        DisplayColumns,
        ShowColumns(
            AddColumns(
                NewSpList,
                NewColumn,
                Switch(
                    SubCategoryDropdown.Selected.Value,
                    "Column1",
                    'Column1',
                    "Column2",
                    'Column2'
     )
            ),
            Title,
            Name,
            EmpStatus,
            NewColumn
        )
    )
  • sivarajan6065 Profile Picture
    23 on at

    Hi @luisveltze ,

     

    I tried yours solution as well and it worked fine, but the problem is it is creating all the columns from the sp list and add the result from the selected column to auto created column. so it is again same dynamic column name, but it really helped me to understand how add and show columns works. 

     

    Thanks mate. Really appreciate.

     

    Regards,

    Siva.

  • WarrenBelz Profile Picture
    154,889 Most Valuable Professional on at

    Hi @sivarajan6065 ,

    So this is now solved ? 

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 547

#2
WarrenBelz Profile Picture

WarrenBelz 444 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 322

Last 30 days Overall leaderboard