cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Chrisguff12
Resolver I
Resolver I

Combobox with textinput showing sum of parts cost

Hello,

Right now, I have a form with a dropdown with a parts list and a textinput that displays the cost of the part from the dropdown. Everything works great, but now I need to change the dropdown to a combo box so that I can select multiple parts and the cost of these will be added together and displayed in the textinput box. Then when I submit the form, I need all of the parts that have been selected put into one field ‘Parts Replaced’ and the combined cost to the ‘Parts Cost’ field on the table. Can you show me how this can be done?

 

My current setup:

Parts_List_Dropdown

Sort(Etching_Parts_Lists,'Item Description',Ascending)

 

Part_Cost_DataCardValue1

LookUp(Etching_Parts_Lists,'Item Description'= Parts_List_Dropdown.SelectedText.Value).'Parts Cost'

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @Chrisguff12 ,

This is not a straight-forward process and what I am supplying should work, but is more syntax guidance to get you on your way. I have it working on a test model here, but have needed to change all the references to the ones you supplied, so if there is an issue please check these and the general logic to what you need. Firstly, if you put this on the OnChange of the Combo Box

Clear(colCosts);
With(
   {wCost: Self.SelectedItems},
   Collect(
      colCosts,
      AddColumns(
         wCost As aCost,
         "Cost",
         LookUp(
            Etching_Parts_Lists,
            'Item Description' = aCost.'Item Description'
         ).'Parts Cost'
      )
   )
)

Now the Default of your Text box containing the new information would be

With(
   {
      wCosts: 
      Concat(
         colCosts,
         'Item Description' & ", "
      )
   },
   Left(
      wCosts,
      Len(wCosts) - 2
   )
) & " - $" & 
Text(
   Sum(
      colCosts,
      Cost
   ),
   "[$-en]###,##0.00"
)

 

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

Hi @Chrisguff12 ,

You just need to split the output into the two fields - first one Parts Replaced

With(
   {
      wCosts: 
      Concat(
         colCosts,
         'Item Description' & ", "
      )
   },
   Left(
      wCosts,
      Len(wCosts) - 2
   )
)

Second one - Parts Cost

"$" & 
Text(
   Sum(
      colCosts,
      Cost
   ),
   "[$-en]###,##0.00"
)

 

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

6 REPLIES 6
WarrenBelz
Super User
Super User

Hi @Chrisguff12 ,

This is not a straight-forward process and what I am supplying should work, but is more syntax guidance to get you on your way. I have it working on a test model here, but have needed to change all the references to the ones you supplied, so if there is an issue please check these and the general logic to what you need. Firstly, if you put this on the OnChange of the Combo Box

Clear(colCosts);
With(
   {wCost: Self.SelectedItems},
   Collect(
      colCosts,
      AddColumns(
         wCost As aCost,
         "Cost",
         LookUp(
            Etching_Parts_Lists,
            'Item Description' = aCost.'Item Description'
         ).'Parts Cost'
      )
   )
)

Now the Default of your Text box containing the new information would be

With(
   {
      wCosts: 
      Concat(
         colCosts,
         'Item Description' & ", "
      )
   },
   Left(
      wCosts,
      Len(wCosts) - 2
   )
) & " - $" & 
Text(
   Sum(
      colCosts,
      Cost
   ),
   "[$-en]###,##0.00"
)

 

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.

Hello @WarrenBelz 

 

Thanks for the quick response and for taking the time to customize the formulas to my data.

 

Both parts you posted are working but for some reason when I select more then one item in the combo box it adds each item twice. 

Cost of the items:

Power supply: $346.09 / Laser Tube: $1,295

Chrisguff12_0-1613784421797.pngChrisguff12_1-1613784466661.png

 

Also I was wondering is there a way to have the Textinputbox only show the price and not the part names? When I submit the form I would like to have the date look like this in on the table. 

Parts Replaced Parts costs
Power supply, Laser Tube$1,641.09

@Chrisguff12 ,

See revised code - should work now. A bit tricky when working with this type of control.

 

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.

Hi, @WarrenBelz 

Thanks that is working better and I'm no longer getting the double results. 

 

In my table it is only returning the one part in the 'Parts Replaced' Field. And the "Parts cost' Field has the part descriptions with the total price. I am guessing that I need to change my Onsuccess Property of the form in order to get the results I want. I have been trying to use the Split function but cant seem to get the correct parts in the right fields.  

Current Results:

Parts ReplacedPart Costs
Blower 230VBlower 120V, Blower 230V - $2,173.00
Power SupplyLaser Tube, Power Supply - $1,641.09

 

I would like it to look like this

Parts ReplacedPart Costs
Blower 120V, Blower 230V$2,173.00
Laser Tube, Power Supply$1,641.09

 

Here is my current OnSuccess Property:

Patch(
    Etching_Maintenance_Reports,
    Down_Machine_Details_Form.LastSubmit,
    {
        'Machine is Down': "False",
        'Parts Replaced': Parts_Replaced_ComboBox.Selected.'Item Description',
        'Part Costs': Parts_Cost_New_TextInput.Text
    }
);

 

BlessedCobba
Resolver I
Resolver I

Try This,
Parts_Cost_New_TextInput.Text has all the output you're after, you just need to split it into the columns you are after for your output

 

Patch(
    Etching_Maintenance_Reports,
    Down_Machine_Details_Form.LastSubmit,
    { 
        'Machine is Down': "False",
        'Parts Replaced': First(Split(Parts_Cost_New_TextInput.Text, "-")).Result, 
        'Parts Cost': Last(FirstN(Split(Parts_Cost_New_TextInput.Text, "-"),2)).Result
    }
)

 

Hi @Chrisguff12 ,

You just need to split the output into the two fields - first one Parts Replaced

With(
   {
      wCosts: 
      Concat(
         colCosts,
         'Item Description' & ", "
      )
   },
   Left(
      wCosts,
      Len(wCosts) - 2
   )
)

Second one - Parts Cost

"$" & 
Text(
   Sum(
      colCosts,
      Cost
   ),
   "[$-en]###,##0.00"
)

 

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.

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 (3,122)