cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BenDonahue
Skilled Sharer
Skilled Sharer

Radio buttons Items set by a variable

The Goal

I am trying to populate the Items for a radio button by assigning the value of variable that contains the array of items to the Items of that radio button control.

 

The Situation

While I am able to get the required string into the variable with this code I put into a button:

BenDonahue_0-1619300230138.png

 

Set(strQGroupCode, "[" & """" & "Clinical Documentation" & """" & "," & """" & "Pediatric Asthma" & """" & "]");

 

and verify that the correct string value is being assigned by putting that variable into the Text property of a label:

BenDonahue_1-1619300348880.png

, when I put that same variable into the Items property of a Radio Buttons control, it does not work:

BenDonahue_3-1619300501859.png

 

The Ask

How do I populate the Items property of a radio button with dynamic values? These values come from a table and can either be supplied in the form shown, or by building it in the Items table with a couple LookUps. Dunno if that helps, but there it is. There may be other sources for getting this information, as I have not built that portion of the app yet, so I can be very flexible. The only requirement is that I take information entered by a user prior to this step to populate the Items for the radio button control.

 

The Thanks

Thank you for your time and help with this, for certain.

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User III
Super User III

Hi @BenDonahue ,

You cannot dynamically set a Variable as a String and then have it interpreted in another place as a Table - they are two different object types.

You can however do a Collection. Here is some test code I did - note the top bit is only to set the Variables - you would simply use yours. The Items of the drop-down is simply colMyDD (or whatever you want to call it)

UpdateContext(
    {
        var1: "Carrots",
        var2: "Tomatos",
        var3: "Onions",
        var4: "Cabbage",
        var5: "Lettuce"
    }
);
ClearCollect(
    colMyDD,
    {Value: var1},
    {Value: var2},
    {Value: var3},
    {Value: var4},
    {Value: var5}
)

You mentioned a Table however - if this is the case - the drop-down would be from a (if necessary) filtered list of this.

 

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.

View solution in original post

2 REPLIES 2
WarrenBelz
Super User III
Super User III

Hi @BenDonahue ,

You cannot dynamically set a Variable as a String and then have it interpreted in another place as a Table - they are two different object types.

You can however do a Collection. Here is some test code I did - note the top bit is only to set the Variables - you would simply use yours. The Items of the drop-down is simply colMyDD (or whatever you want to call it)

UpdateContext(
    {
        var1: "Carrots",
        var2: "Tomatos",
        var3: "Onions",
        var4: "Cabbage",
        var5: "Lettuce"
    }
);
ClearCollect(
    colMyDD,
    {Value: var1},
    {Value: var2},
    {Value: var3},
    {Value: var4},
    {Value: var5}
)

You mentioned a Table however - if this is the case - the drop-down would be from a (if necessary) filtered list of this.

 

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.

View solution in original post

BenDonahue
Skilled Sharer
Skilled Sharer

Beautiful.

 

I swear, with the assistance of generous persons like yourself (and many others), folks in the office think I'm actually good at this (I am the sum total of the dev department, so who's to know otherwise?)  🙂

 

This lesson has brought home something I learned, but did not truly grok, earlier in my Power Apps learning; this help you have provided has really crystalized some vital and intrinsic differences between variables and collections, particularly vis-à-vis their usage and application.


Thank you @WarrenBelz 

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.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,429)