cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rsparks
Level: Powered On

How to go about assigning a number value to each value in a choice dropdown

I have a choice dropdown that allows the user to select from a list of accessories for their vehicle. The purpose of the form is to get a price estimate on a new vehicle. As such, when they select their accessories I need each of these to have a linked value that can be added to a total at the bottom of the page. 

 

For example, they select a sunroof ($1000), floor mats ($100) and a bull-bar ($500). I want the total displayed at the bottom of the form to reflect the $1600 worth of accessories. 

 

Is there a way to do this without the user clicking a "calculate" button that runs the values? I'd like it to all happen as they select the options if possible, to make it easier to see recalculations.

12 REPLIES 12
Highlighted
Edwin-Abdalian
Level 10

Re: How to go about assigning a number value to each value in a choice dropdown

I created a combobox (cmbAccessories) to replicate something similar to your application.combo.PNG

 

Then I created a collection on "On Change" of the combobox:

ClearCollect(colSelectedAccessoriesPrice, cmbAccessories.SelectedItems.Price)

Then I created a label and set the value of it to Sum(colSelectedAccessoriesPrice.Price,Price)

 

now when I make changes to the combo box, the total gets updated automatically.

hope this helps.

 

*************************************************

If I helped you with solving the problem, please choose Accept as Solution and give me a Thumbs Up.

Dual Super User
Dual Super User

Re: How to go about assigning a number value to each value in a choice dropdown

Hey @rsparks 

 

Multiple selection is not allowed in a dropdown bydefault. To enable the multiple selection, I would recommend you to use Combobox control. You can select a Double layout to show both item name and its value.
 
Expression to get the total:
Sum(ComboBox1.SelectedItems,Price)
 
ComboBox1 is the name of control and Price is the name of column which stores the value.
 
If the column that has price is a string type column with $ in it, you can update the expression to:
Sum(ComboBox1.SelectedItems,Value(Substitute(Price,"$","")))
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
rsparks
Level: Powered On

Re: How to go about assigning a number value to each value in a choice dropdown

The combo box is directly linked to a choice column in the sharepoint list, so I don't think I'm able to assign each choice a second value. 

 

Is there still a way to assign them a value in the form? Or alternatively can I patch the results of a freshly created combobox to the choice column in the list?

Edwin-Abdalian
Level 10

Re: How to go about assigning a number value to each value in a choice dropdown

Where do you store the Price?  Do you have a Price List to keep the items and prices? 

rsparks
Level: Powered On

Re: How to go about assigning a number value to each value in a choice dropdown

There is a separate sharepoint list that contains the vehicle make/model and price, as well as insurance/fuel estimates. Based on which make/model the user selects from a drop down, I have some labels doing LookUp functions to find the value of each of the additional costs. 

 

The combo box linked to the choice column however is all within the one column. In sharepoint it gives me the option to put all of the accessories as values for the choice, with the user able to select multiple.

 

Possibly a workaround would be to have a list with each accessory and its value, and look those up based on which accessories are selected in the combobox?

 

 

rsparks
Level: Powered On

Re: How to go about assigning a number value to each value in a choice dropdown

The prices list looks like this:

 

vehicle costs.PNG

 

And the choices column (that is a combobox in powerapps by default) looks like this:

 

choice column.PNG

Edwin-Abdalian
Level 10

Re: How to go about assigning a number value to each value in a choice dropdown

yes, definitely you need a Price List for accessories and you need to bind it to your Combo box. I don't know how complicated your use case can get, but you need a List of Accessories that go only with certain type of cars. For example not all cars can have a rear spoiler.

 

So,

1- You need a Accessories Price List (Required columns : Item, Price)

2- Bind a combo box to the Accessories Price List

3- Patch the combobox selected items to your Estimate List (follow this video)

4-you need a column in your Estimate list for "Total Price of the Accessories" so you patch the total there.

 

I'm sure you will find a way to handle this quickly.

 

*****************************

If my answer solved your problem, please hit Accept As Solution. and If my post was helpful, please give me a Thumbs Up.

rsparks
Level: Powered On

Re: How to go about assigning a number value to each value in a choice dropdown

Would there be any way I could set it up so that the user could see the total cost change without needing to click a button to patch the results?

 

For example, using a few hidden labels to calculate values? If I set up a list with the value for each accessory for each vehicle, could I have a label that reflects the values in the combobox? Even if I set up one label for each combobox option (10 or so). Label1 could be "If combobox value is rear spoiler, then 1, else 0", Label2 could be "If combobox value is roof racks then 1, else 0" etc.

Then another 10 labels that would be "If Label1 equals 1, then Lookup "Vehicle Accessory Costs" with vehicle value as specified in a dropdown further up, and the accessory being rear spoiler". 20 labels total in this instance. Most would have a value of 0, and as such not affect the total price.

 

The final calculation (SUM) field could then just SUM all of the second stage labels. 

 

Could I then use IF statements to determine which accessory price information to patch? IF(Label1 = 1, patch Label1_Price, ""). 

 

Or would it be less effort to get rid of the choice column altogether and simply patch a combobox across, and calculate the values from the combobox as it would simply have 2 values for each option?

Edwin-Abdalian
Level 10

Re: How to go about assigning a number value to each value in a choice dropdown

yes, I'm refering you to my very first reply. the label gets populated automatically without clicking the submit button. users can see the Total price of the accessories in a label.

I wouldn't take that path that you explained, it might work but think about maintaining your application. if you want to make a change in your accessories list then you need to change your app and publish a new one. I'm still voting for a separate nice and clean Price List.

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,678)