cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Manorexia
Regular Visitor

How do I make a calculating conversion table in CDS/PowerApps?

Excuse me for the extremely novice level (I don't even know how to form the question quite right!):

 

I am converting an Excel spreadsheet I made into a PowerApps "recipe calculator" (using CDS), but don't know quite where to begin. 

How I imagine the solution is two tables: Recipes and Base Ingredients. The recipe would be the unique name, ingredient1, ingredient2, ingredient3, (etc) with the values in percentages. The Base Ingredients would be Ingredient1, ingredientA, ingredientB, ingredientC, (etc)... again, with the values in percentages.

 

So, basically, "Ingredient1" is made up of 75% ingredientA, 25% ingredientB, "Ingredient2" is made up of 10% IngredientB and 90% IngredientC. The recipe "Unique123" is made up of 50% "Ingredient1" and 50% "Ingredient2". The calculator would return "IngredientA: 37.5%", , "IngredientB: 17.5%", and "IngredientC: 45%".

 

The actual calculator would be a dropdown that selects the recipe (displaying the name) and a list of the TOTAL amount (in percent) of the A-Z ingredients. 

 

The issue I'm running into is how to link the two tables together to perform the calculation. In Excel, I just did the calculation in the field of the Base Ingredients.

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @Manorexia ,

1)I suggest you create 2 tables(Recipes and Base Ingredients)

table1: Base Ingredients( what is "Ingredient1","Ingredient2",... made up of)

The structure of the table is:

IngredientID(text)          A (floating point number)           B          C

Ingredient1                    0.75                                           0.25 

Ingredient2                                                                       0.1         0.9

 

table2: Recipes( what is recipe "Unique123" made up of)

The structure of the table is:

recipeName     Ingredient1        Ingredient2 

Unique123         0.5                      0.5

 

2)insert a drop down, a button, a datatable.

Set the drop down's Items: Recipes      Value:recipeName

Set the button's OnSelect:

ClearCollect(test,{recipe:Dropdown2.Selected.recipeName,
A:LookUp(Recipes,recipeName=Dropdown2.Selected.recipeName,Ingredient1)*
LookUp('Base Ingredients',crb4c_ingredientid="Ingredient1",A)+
LookUp(Recipes,recipeName=Dropdown2.Selected.recipeName,Ingredient2)*
LookUp('Base Ingredients',crb4c_ingredientid="Ingredient2",A),
B:LookUp(Recipes,recipeName=Dropdown2.Selected.recipeName,Ingredient1)*
LookUp('Base Ingredients',crb4c_ingredientid="Ingredient1",B)+
LookUp(Recipes,recipeName=Dropdown2.Selected.recipeName,Ingredient2)*
LookUp('Base Ingredients',crb4c_ingredientid="Ingredient2",B),
C:LookUp(Recipes,recipeName=Dropdown2.Selected.recipeName,Ingredient1)*
LookUp('Base Ingredients',crb4c_ingredientid="Ingredient1",C)+
LookUp(Recipes,recipeName=Dropdown2.Selected.recipeName,Ingredient2)*
LookUp('Base Ingredients',crb4c_ingredientid="Ingredient2",C)
}
)

Set the datatable's Items: test619.png

 

 

 

Best regards,

Community Support Team _ Phoebe Liu

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yutliu-msft
Community Support
Community Support

Hi @Manorexia ,

1)I suggest you create 2 tables(Recipes and Base Ingredients)

table1: Base Ingredients( what is "Ingredient1","Ingredient2",... made up of)

The structure of the table is:

IngredientID(text)          A (floating point number)           B          C

Ingredient1                    0.75                                           0.25 

Ingredient2                                                                       0.1         0.9

 

table2: Recipes( what is recipe "Unique123" made up of)

The structure of the table is:

recipeName     Ingredient1        Ingredient2 

Unique123         0.5                      0.5

 

2)insert a drop down, a button, a datatable.

Set the drop down's Items: Recipes      Value:recipeName

Set the button's OnSelect:

ClearCollect(test,{recipe:Dropdown2.Selected.recipeName,
A:LookUp(Recipes,recipeName=Dropdown2.Selected.recipeName,Ingredient1)*
LookUp('Base Ingredients',crb4c_ingredientid="Ingredient1",A)+
LookUp(Recipes,recipeName=Dropdown2.Selected.recipeName,Ingredient2)*
LookUp('Base Ingredients',crb4c_ingredientid="Ingredient2",A),
B:LookUp(Recipes,recipeName=Dropdown2.Selected.recipeName,Ingredient1)*
LookUp('Base Ingredients',crb4c_ingredientid="Ingredient1",B)+
LookUp(Recipes,recipeName=Dropdown2.Selected.recipeName,Ingredient2)*
LookUp('Base Ingredients',crb4c_ingredientid="Ingredient2",B),
C:LookUp(Recipes,recipeName=Dropdown2.Selected.recipeName,Ingredient1)*
LookUp('Base Ingredients',crb4c_ingredientid="Ingredient1",C)+
LookUp(Recipes,recipeName=Dropdown2.Selected.recipeName,Ingredient2)*
LookUp('Base Ingredients',crb4c_ingredientid="Ingredient2",C)
}
)

Set the datatable's Items: test619.png

 

 

 

Best regards,

Community Support Team _ Phoebe Liu

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,655)