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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (25,128)