# QP02 Formula for Arithmetic Mean

I have 4 MIC (C0010, C0020, C0030, C0040) and i want C0050 to be the average (or arithmetic mean, depending on the number of values) of the 4 MIC. But there may be times that not all 4 MIC will have any value (maybe zero). What formula do i use?

10|10000 characters needed characters exceeded
• Thank you for visiting SAP Community to get answers to your questions. Since you're new in asking questions here, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't already), as it provides tips for preparing questions that draw responses from our members. For example, you can outline what steps you took to find answers (and why they weren't helpful), share screenshots of what you've seen/done, make sure you've applied the appropriate tags, and use a more descriptive subject line. The more details you provide, the more likely it is that members will be able to assist you. You should also make sure you're using all the appropriate tags, so the right experts can find your question.

Should you wish, you can revise your question by selecting Actions, then Edit (although once someone answers your question, you'll lose the ability to edit the question -- but if that happens, you can leave more details in a comment).

Best regards

Mynyna

SAP Community moderator

### Related questions

• Posted on Jul 27, 2020 at 12:41 PM
10|10000 characters needed characters exceeded
• Posted on Jul 28, 2020 at 11:40 AM

I think you will need to develop your own formula value for this. i.e. Z10010.

So for whatever MIC has Z1 for its formula, that would be the MIC that is the mean.

The Z1 function module would have to determine which MICS to utilize, You'll have to come up with a scheme do this. You would only specify one MIC in the formula even though you might average a multiple MICS.

Two possible ways for FM to know which Characteristics to average:

- average all other MICS in the operation. (basically means each average is its own operation)

- Look at the info1 field of the calculated MIC. Use that to find the other MICS to average. I.e. you put in AVG1 into the info field 1. It would then average together all other MICS with AVG1 in the info1 field as well.. This way you could perform multiple averages in an inspection lot.

PLAN charc, Info field 1

• 0010 AVG1
• 0020 AVG1
• 0030 AVG1
• 0040 AVG1
• 0050 AVG1 Z10010
• 0060 AVG2
• 0070 AVG2
• 0080 AVG2 Z10010

In the Z1 formulas above the characteristic used doesn't mean anything. It just needs something to make it syntactically correct. The FM would need to have all the logic. I.e. for 0050 it looks for Z1 looks at itself and sees AVG1 in the info field and than averages 0010-0040 because they also have AVG1 in info field 1. 0080 only looks at 0060 and 0070 because they are only other characteristics with AVG2 in info field 1.

in the FM, you would then do a second check to get all non-zero values from the relevant characteristics and perform the average and return that value to the calculated characteristic.

Craig