# custom calculation on several specific compounds

Hi,

Just need a reminder on formulating custom calculation (Chemstation ver.C.01)  as I haven't worked on it for years and feel something is missing from my memory.  I have got several LC peaks with specific compound names, eg. A, B, C and D, and I need to build calculations arounds these peaks. Eg. to get ratios of (C+D)/(A+B) in different batches.  How do I refer these specific compound peaks in a table to do the calculation?

Many thanks for anyone's help.

• I work in CDS so it may be slightly different, but from videos online it looks pretty similar so I'll tell you how I would go about it. I will use curly brackets {} for when the text I put should be modified or replaced.

1. Make 4 different text fields (one for each compound).
2. Put a group around each individually
3. Set the group repeat =1
4. Filter by Compound_Name = {the compound name}
5. Group all four groups into a larger group
6. Make this group invisible (on the group repeat options tab)
7. Repeat by Injection_ID
8. Filter out sample types you don't want (such as blanks). Refer to sample_type enumeration list for the values here.
9. In the formula of each text field, set it equal to =Peak_Area
10. Save as a Custom Calculation Variable Named {compound name}Area and unique key = Injection_ID
11. Make your table with any raw statistics you want (such as Sample_Name, Sample Description, etc). I would recommend using one of the defaults that starts out displaying statistics about each injection so you don't have to mess with any filtering, repeating, or sorting properties.
12. Make a new column at the end with custom calculation.
13. Make the formula of the custom calculation =({compound name C}Area(Injection_ID)+{compound name D}Area(Injection_ID))/({compound name A}Area(Injection_ID)+{compound name B}Area(Injection_ID))

This should give you a table with the wanted ratio calculated for individual injections. If you want to do average, then I would recommend doing this outside of a table since the average of the ratios may not necessarily be equal to the ratio of the averages and the table will only give you the first with the preset aggregates. If you want to do the second, simply remove the grouping by injection ID around the 4 groups, make each one invisible, and change the formula to be =Avg(Peak_Area) instead, then do the final ratio calculation with the same formula as recommended for the table but in its own text field. If you have multiple batches in one run, then you will need to group the four again but determine some criteria that separates them (such as batch number, if you have that as a custom field in the project), then do the same calculation, but repeat on batch number.

Hope this helps,

Cole

• Hi Cole, many thanks for your swift response, I will give it a go and see if I can make it working again on my end..

• Yeah, just let me know if you're having any issues

• Hello,

You might want to look at using compound groups, if you need the summed peaks to change in the future it would be more flexible.  If you use compound groups, you could setup something like what I have below. I created a group in IR with 2 fields, the sample name and a custom field, then repeated it by injection ID. Set a filter on the group for compound type = 4 which is named groups. Then in the custom field, I set the name to =Last(Compound_Name) & "/" &  First(Compound_Name) and the value to =Last(Compound_AreaSum)/First(Compound_AreaSum). I did not test this in Chemstation but it should work in most versions as compound groups are setup differently but work the same way in IR. Please note this only works in cases where you have 2 distinct elements in your list of values for the field. Also, I have the names in the field to check the order. If your group names are not in the same order as mine, you will need to change the position of the first and last values in the ratio and name.

Marty