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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Select column using va...
Power Apps
Answered

Select column using variable in canvas app?

(1) ShareShare
ReportReport
Posted on by 664

Is it possible to get a column by anything other than dot notation in a canvas app? I want to dynamically select a specific column based on some other logic. For example let's say I have a global variable called gblColName which is set to "Column 1" in the OnStart.

There is a Dataverse table with columns Column 1, Column 2, and Column 3. If I were showing the items from the table in the gallery, I could show a label with each value using ThisItem.'Column 1'

I'm trying to do something like ThisItem.gblColName or ThisItem[gblColName], which don't work. Hope this makes sense but anyone know of how I could accomplish this?

Categories:
I have the same question (1)
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Cooper01 

    You cannot reference controls, fields/columns, etc like that in PowerApps.

    You will need to apply a logic formula to determine what is displayed.

    Ex.

    Switch(glbColName, 
     "Column 1", ThisItem.Column1,
     "Column 2", ThisItem.Column2,
     etc..
    )
    
    

     

    I hope this is helpful for you. 

  • Cooper01 Profile Picture
    664 on at

    Thanks @RandyHayes. Was hoping to avoid this because my actual logic would result in quite a lengthy Switch statement but appreciate the confirmation that this is the only way.

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Cooper01 

    Yep...I have posted an idea in the idea forum on this a long time ago.  You can certainly go to that Idea and vote on it too.

  • HEATFreight Profile Picture
    1,024 on at

    Is there really no way to "de-literalize" the string, so to speak?

    Seems like there should be some hacky notation to escape a string literal into its equivalent column reference. You should be able to nest string variables within the Power FX decimal notation. Is there some reason they disallow that other than the complexity of implementing it as a feature?

  • jaredbidlow Profile Picture
    256 on at

    Following

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard