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

Reflecting price updates through app

Hi all, 

 

I work in a research lab and I am building an app that will allow us to "build" liquid reagents using items from our vendors. To do this, I have a table of commercially available items. I then want users to be able to select multiple items and add to a collection, adjust the volumes that they will use, and create a new item that will be the final custom reagent. This will then sum the price of all the components. 

 

What I want to be able to do is dynamical change the price of those custom items when the price of the components is updated. For example:

 

Reagent A (Table: Reagents) consists of:

Item 1 (Table: Items) - $5.00

Item 2 (Table: Items) - $10.00

Item 3 (Table: Items) - $15.00

Total = $30.00

 

Six months later, the cost of Item 1 increases to $30.00 so I update that price in Table:Items . How can I ensure that the price for Reagent A increases by $25.00? 

 

The first thing I imagine is that I will need a "middle" table where I can link Reagent and Items so that I can maintain a list of the items that make up Reagent A. However, I am thinking like a database designer where records are related and can be dynamically updated with little effort, but I know powerapps does not work the same. Any suggestions would be great. Let me know if I need to provide a better example. 

1 REPLY 1

Re: Reflecting price updates through app

Hi @cah2035!

 

I think you need to have a relation table for the BOM in between, because you need to have a link between the Reagent and the components. I made a test from my side that worked like a charm 🙂 This is what I did:

 

1. I created three tables (in my case Collections but this works for other sources as well); one for the Reagents, one for the Items, and one for the BOM table (Link). The Reagents just contains a ReagentId and Price. Items contains ItemId and Price. The BOMTable contains ReagentId and ItemId

 

2. I also created a button for the calculation. My idea is to simplify this by making a total regeneration of the Price for the Reagents, not just for the affected ones. Below you find the code for the calculation and update of the Price (OnSelect):

 

First, I create a Temp collection which is basically the same as the BOMTable but with an addition of the price of the component.

Second, I create a Temp collection for the Reagents. Not necessary but it´s easier when you have different column names when you filter etc.

Third; Here is where I do the calculation and update of the Reagents table. I go through each record in Reagents and update the Price based on the Sum of the Prices for components related to the Reagent item.

 

ClearCollect(
    TmpLink,
    AddColumns(
        BomTable,
        "PricePcs",
        LookUp(
            Items,
            ItemId = Component,
            Price
        )
    )
);
ForAll(
    Reagents,
    Collect(
        TmpReagent,
        {
            Id: ReagentId,
            Prices: Price
        }
    )
);
ForAll(
    TmpReagent,
    Patch(
        Reagents,
        LookUp(
            Reagents,
            ReagentId = Id
        ),
        {
            Price: Sum(
                Filter(
                    TmpLink,
                    ReagentItem = Id
                ),
                PricePcs
            )
        }
    )
)

 

Hope this might help you forward 🙂

BR

Pontus

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps 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

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (6,024)