Forum Discussion
Nishkarsh31
Apr 11, 2021Brass Contributor
How to sum an array, after applying a few conditions to it? It's complicated, I'm attaching a file.
I'm attaching a file. It's self explanatory. I wanna convert the array to be summed base on a different array and then do the final summation. Is it possible to achieve this without adding a he...
PeterBartholomew1
Apr 11, 2021Silver Contributor
A formula for the cost could be
= LET(
unitCosts,
Ingredient[Cost] * SWITCH(Ingredient[Unit],"kg",1,"g",1000,"lt",1,"ml",1000),
qty, Recipe[Qty1] / SWITCH(Recipe[Unit1],"kg",1,"g",1000,"lt",1,"ml",1000),
cost, qty * XLOOKUP(Recipe[Recipe 1],Ingredient[Ingredient],unitCosts),
SUM(cost)&" INR")
The weight and volume of dry and liquid ingredients are given by
= SUM(SUMIFS(Recipe[Qty1], Recipe[Unit1],{"kg","g"}) * {1,0.001})& " kg"
= SUM(SUMIFS(Recipe[Qty1], Recipe[Unit1],{"lt","ml"}) * {1,0.001}) & " lt"
respectively.
You could always try the LAMBDA function so that the same formula can be applied to recipe1 and recipe2, but that is probably several steps too far.