cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sanj_
Frequent Visitor

Use Choice/Person fields in ShowColumns function

Hello Community,

 

Please bear with me as I am new to Power Platform. 

 

My Question is how can we use Choice or Person fields in 'ShowColumns' function in PowerApps?

 

Ex: ClearCollect(collectionA, ShowColumns(Student, "ID", "Name", "Country", "Mentor"))

 

In here Country is a 'Choice Field' and Mentor is a 'Person Field' in SharePoint. I want to get the Display Name of the 'Mentor' and Value of the Country.

 

In my Gallery control I can use 'Mentor.DisplayName' and 'Country.Value' but in ShowColumns function it doesn't allow to use the same way.

 

Please help.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Sanj_ ,

You can call the added columns anything except the original names

ClearCollect(
   collectionA, 
   ShowColumns(
      AddColumns(
         Student,
         "Nationality",
         Country.Value,
         "Teacher",
         Mentor.DisplayName
      ),		 
      "ID", 
      "Name", 
      "Nationality", 
      "Teacher"  
   )
)

 

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.

Visit my blog Practical Power Apps

View solution in original post

4 REPLIES 4
phipps0218
Memorable Member
Memorable Member

The ShowColumns function includes columns of a table and drops all other columns. You can use ShowColumns to create a single-column table from a multi-column table. ShowColumns includes columns, and DropColumns excludes columns.

Essentially this will provide you a collection with a table of "ID", "Name", "Country", "Mentor". What do you want to do with that collection? You can then use LookUp function to get values from this collection.

Please Accept as Solution if it solves your question. Or just give it a Thumbs Up if it is helpful as can help others.

LinkedIn: https://www.linkedin.com/in/charlie-phipps-%F0%9F%91%A8%E2%80%8D%F0%9F%92%BB-91338715b/
YouTube: https://www.youtube.com/channel/UChmFBGU1YKIU91sNMQ7buGg
Twitter: https://twitter.com/phipps0218

Sanj_
Frequent Visitor

Hello @phipps0218 

 

Thank you for your prompt response. 

 

'Mentor' is a person field and 'Country' is a choice field in SharePoint. If I used the below method, it doesn't give me the the values for 'Mentor' and 'Country'.

 

ClearCollect(collectionA, ShowColumns(Student, "ID", "Name", "Country", "Mentor"))

 

Simply I want to get the DisplayName of 'Mentor' and Value of 'Country' when creating collection.

 

Like:

ClearCollect(collectionA, ShowColumns(Student, "ID", "Name", "Country".Value, "Mentor".DisplayName))

 

 

 

Hi @Sanj_ ,

You can call the added columns anything except the original names

ClearCollect(
   collectionA, 
   ShowColumns(
      AddColumns(
         Student,
         "Nationality",
         Country.Value,
         "Teacher",
         Mentor.DisplayName
      ),		 
      "ID", 
      "Name", 
      "Nationality", 
      "Teacher"  
   )
)

 

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.

Visit my blog Practical Power Apps

Sanj_
Frequent Visitor

Hi @WarrenBelz 

 

It worked for me. Thanks a lot. 🙂 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,631)