cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Julien2
Post Prodigy
Post Prodigy

Add two options to a choice (Option set) column using a collection

Hello everyone,

I have a status choice field in a table in dataverse that has some values and I would like to add two extra options to a choice (Option set) column using a collection in Power Apps canvas.

I have tried the below:
ErrorAddAnOption.png

When I add a string to the value parameter the formula highlights an error. If I keep the Blank() function it is working but it seems that the choice (option set) is expecting a different data type?

Blank()Blank()
The SharePoint Choice column is very straight forward and it doesn't throw an error:
SharePoint status column.png

What should be the updated formula in order to add two or more options for a choice (option set) column? Can please someone provide an example?

Any help is highly appreciated.

Thank you!

9 REPLIES 9
AJ_Z
Super User
Super User

I usually add more in the source e.g. the sharepoint site but what happens when you wrap square brackets around it e.g. {Value:["Pending"]},{Value:["All"]}. 

If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !

Julien2
Post Prodigy
Post Prodigy

Hello @AJ_Z,
I also do the same by adding more options to the source but for my scenario, I just want to filter the data in the gallery by populating the choices option and I am trying that option to learn something new by adding an option value using the choice (option set) field using a collection.
I wrapped square brackets around value but it is still showing the same error:
Capture.PNG
What might be the trick to make it work?
I look forward to your response.
Thank you!

Apologies I misread your post. For something like this I make the collection usually:

ForAll(Choices('Time Entries'.'Approval Status'),Collect(colChoices,{Value:ThisRecord.Value}));Collect(colChoices,{Value:Blank()},{Value:"Pending"},{Value:"All"});

 

then i make the items in a combobox usually into the collection name which in this case is as colChoices

If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !

Hello @AJ_Z ,

Thank you for your reply.
I have tried the below formula that you mentioned and I got the same error:
Screenshot 2022-01-18 085419.png
What is wrong with the formula?
Thank you!

My initial thoughts with this regarding errors are conflicting names 🙂 

 

perhaps try changing it to:

 

ForAll(Choices('Time Entries'.'Approval Status'),Collect(colChoices1,{Value:ThisRecord.Value}));Collect(colChoices1,{Value:Blank()},{Value:"Pending"},{Value:"All"});

 

if no joy with that try to see what options appear after ThisRecord i would expect it to be value but it could be something else. So when you go back to ThisRecord the area in red below type in the "." and see what options come after I am expecting it to be Value but it could be something else.

 

ForAll(Choices('Time Entries'.'Approval Status'),Collect(colChoices1,{Value:ThisRecord.Value}));Collect(colChoices1,{Value:Blank()},{Value:"Pending"},{Value:"All"});

 

As part of trouble shooting try the two steps separately on diff buttons maybe? e.g.

 

Collect(colChoices1,{Value:Blank()},{Value:"Pending"},{Value:"All"}); on one and

ForAll(Choices('Time Entries'.'Approval Status'),Collect(colChoices1,{Value:ThisRecord.Value})) on the other.

 

let me know how this goes. My initial thought is that there were already values in colChoices so i am suggesting trying colChoices1. If this doesn't work let me know 🙂 ?

If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !

Julien2
Post Prodigy
Post Prodigy

Hello @AJ_Z ,

Thank you for your reply and for providing an example.

I have tried all the steps mentioned with no hope.
Screen1.png
After ThisRecord the option is .Value which is the right one that we're using.

For troubleshooting I have added two separate buttons:

When I added the second button that has the below line of formula, both formulas fails with an error:
Screen2.pngScreen3.png

It is really strange why it is not working.

I look forward to your response.
Best regards,
Julien

Julien2
Post Prodigy
Post Prodigy

Hello @AJ_Z ,

I have used "ThisRecord" instead of "Value" as the key and it worked 😀.
Screen1.PNGScreen2.PNG

I don't know if this is the right solution but I ended up getting this formula in this way.
Please let me know if it is the right solution.

Thank you!

 

It doesn't look as I expected does it give you all the values you needed from choices?

If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !

Hi @AJ_Z ,

Yes, it gives me all the values needed from the choice, please find the below screenshots:
Screenshot 2022-01-20 170518.pngOptionValues.png
But I still didn't understand how did it work 😂.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,465)