Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Iterative/Recursive Calculations

Hi   I have a table of products and ingredients:   Product Ingredient Initial price A D 2 A B 0 B C 0 C E 2   As you can see, product A contains products D and B. ...
  • Anonymous's avatar
    Anonymous
    6 years ago

    Please find the PQ solution attached. When you open, please go to Power Query and have a look at the function I created to get the price of a product. The assumption is that products are in the first column and only for them do you have to calculate the total price.

     

    Original Data is the table with your original data.

    Products with final prices is the table with final prices.

    getTotalProductPrice is the function that does the recursion...

     

    You have to check this procedure against a representative number of cases because I used your data and made assumptions which might not be true about the full set. You have to TEST.

     

    Best

    D