Forum Discussion
Cumulative Average of other percentages (non-contiguous range)
Please help me figure out a formula to calculate the cumulative average of the semester averages. Keep in mind that many of the semester grades will be 0 because we haven't reached those semesters yet. I need a formula that will show " the real time" program cumulative average.
8 Replies
- pefirdCopper Contributor
This should do the trick.
=SUM(H54,H91,H128,H150)/SUM(H54>0,H91>0,H128>0,H150>0)
Will add up all the grades and divide them by the grades greater than 0. The Sum portion of the calculation returns True/False counted as 1/0.
- SnowMan55Bronze Contributor
The formula with the AVERAGEIFS function that you wrote suggests that you are not reading the documentation on that function. That function requires 3 arguments (or 5, or 7…), and you are supplying only 2 arguments (a range and a literal). (The arguments are different than those for the AVERAGEIF function.)
Here are links to all the Microsoft documentation for Excel's built-in functions: listed alphabetically and listed by category
Community member pefird gave reasonable suggestions. But if you do not want to change the structure of the worksheet/workbook that much…
Because Excel formulas cannot determine the current fill color of a cell*, the formulas have no simple way to determine which rows contain the values that you want to average. And it is preferable to avoid "hard-coding" the specific cells you want to use.* Technically, they can, but it involves creating a custom function in VBA. That increases complexity, requires a different file format, and raises security concerns.
This structure of the data is currently not well-suited for the AVERAGEIFS function. The rows to be summarized are neither consistently spaced, nor is there a consistent number of them, nor is there any simple identifier for those rows.
I suggest that you insert a column somewhere before the current column G (the first student's data). This new column can be hidden, once it is populated. For each "important" row, you would load the column with a combination of a semester identifier and a row-type identifier.Or you can use column F and change the formatting to hide these values. I can suggest values of S1S (semester 1 summary) for row 6 and S1CS (semester 1 course summary) for rows 7, 20, 24, and 41.
See the attached workbook for this latter kind of solution. As you did not attach a workbook to your post (or make a workbook available through a file-sharing service), and the images were of low quality, I set up only part of the data, and part of the visual formatting. - pefirdCopper Contributor
Easiest resolution is to summarize at the top of the spreadsheet by inserting a few lines.
This could also be placed at the bottom or on a different tab. Averageif requires a "range".
- C_SCopper Contributor
My issue is that I need a formula to calculate the “real time” program cumulative grade average of all the non-contiguous semester grade averages for each student that is not 0%.
I need cell G3 in the image to be the cumulative average of cells H6, H54, H91, H128 & H150.
Each semester average (cells H6, H54, H91, H128, H150) is the average of the weighted averages of each subject (H7, H20, H34, & H41) in that semester for that student. - Harun24HRBronze Contributor
Can you please attach a sample excel file to your post?
- C_SCopper Contributor
- Mks_1973Iron Contributor
To calculate the cumulative average of semester grades in Excel for a non-contiguous range, while ensuring that only the non-zero semester averages are considered, you can use an array formula
Use the following formula to calculate the program cumulative average:
=SUM(H6,H54,H91,H128,H150)/COUNTIF(H6:H150,">0")NOTE: Replace H6, H54, H91, H128, H150 with the exact cells in your table.
If you're using older versions of Excel, you may need to confirm the formula with CTRL+SHIFT+ENTER to make it an array formula. However, in most modern versions of Excel, this is not necessary.
Explanation:This formula ensures: Only semesters with grades greater than 0 are included in the calculation. The average is adjusted dynamically as new semester grades are entered.
SUM(H6,H54,H91,H128,H150): Adds up the semester averages. Since the cells are non-contiguous, explicitly list them in the SUM function.
COUNTIF(H6:H150,">0"):Counts only the cells with values greater than 0, ensuring that semesters with a grade of 0 are excluded.
Division:Divides the total of non-zero semester averages by the count of those semesters, giving the real-time cumulative average.- C_SCopper Contributor
I tried the formula you recommended, and it provides an incorrect answer because the COUNTIF part of the formula includes values in the range that is not supposed to be included. When I tried only selecting the non-contiguous cells, I get an error message of too many arguments .