cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cooper01
Continued Contributor
Continued Contributor

Select column using variable in canvas app?

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?

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@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. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

3 REPLIES 3
RandyHayes
Super User III
Super User III

@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. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Cooper01
Continued Contributor
Continued Contributor

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
Super User III
Super User III

@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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (976)