cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cooper01
Responsive Resident
Responsive Resident

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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Cooper01
Responsive Resident
Responsive Resident

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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (46,679)