web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Combobox with defined ...
Power Apps
Answered

Combobox with defined options and different values for each option

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello all,

I have a question regarding combobox. So far I have used CBs with data that is from an Excel sheet with, for example, 'DISTINCT' on the items property in order to have the options on the list. However, now I want to have a CB list with defined values that are not in any part of the data, and would always be the same. In this case, I would want to have the CB list with values: "0% / 25% / 50% / 75% / 100%". How can I do this? Or do I need to create a table with those values in order for the CB to read it?

And a follow-up question I have is: when an option in the CB is chosen, how can I make it so if, for example, "25%" is chosen, when the form is saved (in an editform), instead of that, another value is saved? For example: If CB=25%, "A1"

 

 

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    69,226 Most Valuable Professional on at

    If the list of values isn't too large I think the easiest way to get values in a combobox is to create a collection using the OnStart method of the app.  Put something like this into the OnStart

     

    ClearCollect(CB,{Text:"25%",Value:"a1"},{Text:"50%",Value:"a2"},{Text:"75%",Value:"a3"})

     

    Then Bind the Items property of the Combobox to the collection, in this case 'CB'. AS you can see I'm binding both a Text and a Value property to the combobox.  The value is what you will retrieve and store when you save the record back to the data source. When binding from an Excel datasource it makes the Text and value the same.

     

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    You can specify what you want for data in combo boxes as well as most all of the other controls.

    For your case, you can set the Items property of the ComboBox to the following:

     

    ["0%", "25%", "50%", "75%", "100%"]

    This will create a single column table data source for your combobox.  It will have a Value column (which is what you would choose to display).

     

    So, later you can reference that value for any other conversions.  For example, in your Update property, you can put in logic to convert such as this:

     

    Switch(comboBoxx.Selected.Value,
    "0%", someOtherValueFor0,
    "25%", someOtherValueFor25,
    etc
    )
    

    However, another option you can choose is to define the alternate value as part of the datasource you create in the Item property.

     

     

    So, for example, if conversion to numbers rather than text is what you want, then you can do something like this in the Items property:

     

    Table({Value:"0%", Number:0}, 
    {Value:"25%", Number:.25},
    {Value:"50%", Number:.5},
    {Value:"75%", Number:.75},
    {Value:"100%", Number:1})

    This will create a two column table with a Value text column and a Number numeric column.

    Then later on in your Update, you can reference the number assigned to that value, for example:

    comboBoxx.Selected.Number

     

    I hope this is clear and helpful for you.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you both very much. This will help me a lot (:

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RandyHayes 

    I have a follow-up new question:

    In the form I have now I have 2 different columns/datacards, one with the % from the CB, and another that has a value depending on the selected one in the CB. How would I go using the value of the CB as a criteria in an IF?
    It is like the previous case however it is in another datacard now.

    I tried using:

    If(Text('Porcentaje cumplimiento_DataCard1'.Default)="0%", "4+")

    And also:

    If(DataCardValue5.Selected.Value="0%", "4+")

    However in both cases the box keeps empty. What am I doing wrong?

    cb_depending.png

     

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Some of this will depend on which of the suggestions were implemented.  If you chose the Text only items or the table based set of records, that would assist in your answer.

     

    Let's assume you took the list of text values only (first suggestion example).

    First, a little simplification of the formula (just to make it easier to read):

       If(areaVar.Result="Prevencion de Riesgos" && idForm="1" && DataCardValue5.Selected.Value="0%", "4+")

    This should work - in fact it would work for either choice of suggestion you took (based on how they were defined).

    So, begs the question, what are the values of areaVar.Result and idForm, and is idForm a text or numeric value?

    In the past, I'd say "throw a label on the screen to troubleshoot", but you can now just turn on the new "Enable formula bar result view" in the app settings and you can now see directly in your designer what those values are.

    This will help tremendously in troubleshooting the issue.

     

    Next (just to be complete), let's assume you took the second suggested formula - the table of value and number records. If so, your formula could be as such:

       If(areaVar.Result="Prevencion de Riesgos" && idForm="1" && DataCardValue5.Selected.Number=0, "4+")

    This would work equally well.

    BUT...the question still remains - if you are getting nothing, I suspect the other factors in the formula condition to be at issue.

     

    To truly push this, you could change your formula to the following:

       If(DataCardValue5.Selected.Value="0%", "4+")

     

    If this shows "4+", then the issue is with the other conditional evaluations.

     

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RandyHayes 

    That was exactly what I needed. Again, thanks.

    I enabled that option and saw that it was a spanish character that was messing the formula, so to speak, since "o" is not the same than "ó", hence, it was giving a false.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 534

#2
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard