# Sum Quantities Of Alike Items - SQL Alternative?

## Recommended Posts

I was kind of referring to this problem a week or so ago, but the presentation of the problem was poor and some things are different.

I have three calculated fields that are being used to sum up the entered quantities of specific items. There are 6 fields each - the user will select the type of 'IG' from the left dropdown and put the quantity that they want in the field to the right of it. In the image below, if 'Alum' was selected and '5' was put in the Qty field, we would start with 5 Alum IGs.

Now I need to group together alike 'IGs' and sum their quantities. I have 3 calculated fields to account for the 3 IG types, with this formula (the WHEN clause values are Vinyl = 1, Alum = 2, Wood = 3):

```CASE
WHEN [@field:IG_Sheet_Table_IG1] = "1"
THEN [@field:IG_Sheet_Table_IG1_Qty]
ELSE 0
END
+
CASE
WHEN [@field:IG_Sheet_Table_IG2] = "1"
THEN [@field:IG_Sheet_Table_IG2_Qty]
ELSE 0
END
+
CASE
WHEN [@field:IG_Sheet_Table_IG3] = "1"
THEN [@field:IG_Sheet_Table_IG3_Qty]
ELSE 0
END
+
CASE
WHEN [@field:IG_Sheet_Table_IG4] = "1"
THEN [@field:IG_Sheet_Table_IG4_Qty]
ELSE 0
END
+
CASE
WHEN [@field:IG_Sheet_Table_IG5] = "1"
THEN [@field:IG_Sheet_Table_IG5_Qty]
ELSE 0
END
+
CASE
WHEN [@field:IG_Sheet_Table_IG6] = "1"
THEN [@field:IG_Sheet_Table_IG6_Qty]
ELSE 0
END```

1 case statement for each IG/Qty and adding them together. These 3 formulas are making my page insanely slow.

I am looking for some help on how to rearrange this formula or how to accomplish this in another way that might help with the load times on my page.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.