(Excel examples for Beginners)
In this end-to-end excel example, you will learn – Excel formula for Beginners – How to find Max of every nth column in Excel.
Excel formula for Beginners – How to find Max of every nth column in Excel
Generic formula
{=MAX(IF(MOD(COLUMN(rng)-COLUMN(rng.first)+1,n)=0,rng))}
Summary
To get the max of every nth column, you can use an array formula based on the MAX, MOD, and COLUMN functions. In the example shown, the formula in M5 is:
=MAX(IF(MOD(COLUMN(B5:K5)-COLUMN(B5)+1,L5)=0,B5:K5))
Note: this is an array formula and must be entered with control + shift + enter.
Explanation
This formula uses the MOD and COLUMN functions to filter out values not in nth columns, then runs MAX on the result.
The key is this snippet:
MOD(COLUMN(B5:K5)-COLUMN(B5)+1,L5)=0
Here, the formula uses the COLUMN function to get a set of “relative” column numbers for the range which looks like this:
{1,2,3,4,5,6,7,8,9,10}
This array goes into the MOD function as the number argument:
MOD({1,2,3,4,5,6,7,8,9,10},K5)=0
where L5 is the the value to use for “nth”. The MOD function returns the remainder for each column number divided by N. So, for example, when N = 3, MOD will return an array like this:
{1,2,0,1,2,0,1,2,0,1}
Note that zeros appear for columns 3, 6, 9, etc., corresponding to every 3rd column. This array is compared to zero with the logical expression =0 to force a TRUE when the remainder is zero and a FALSE when not. These values go into the IF function as the logical test. The IF function filters accordingly, so only values in the original range in nth columns make it into the final array. The other values become FALSE.
When n = 3, the final array inside MAX looks like this:
MAX({FALSE,FALSE,11,FALSE,FALSE,8,FALSE,FALSE,19,FALSE})
Finally, the MAX function ignores FALSE values and returns the maximum of remaining values, 19.
Max of every other column
If you want to get the max of every other column, just adapt this formula as needed, understanding the formula automatically assigns 1 to the first column in the range. To get the max of EVEN columns, use:
{=MAX(IF(MOD(COLUMN(A1:Z1)-COLUMN(A1)+1,2)=0,rng))}
To get the max of ODD columns, use:
{=MAX(IF(MOD(COLUMN(A1:Z1)-COLUMN(A1)+1,2)=1,rng))}
Excel formula for Beginners – How to find Max of every nth column in Excel
Disclaimer: The information and code presented within this recipe/tutorial is only for educational and coaching purposes for beginners and developers. Anyone can practice and apply the recipe/tutorial presented here, but the reader is taking full responsibility for his/her actions. The author (content curator) of this recipe (code / program) has made every effort to ensure the accuracy of the information was correct at time of publication. The author (content curator) does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause. The information presented here could also be found in public knowledge domains.
Learn by Coding: v-Tutorials on Applied Machine Learning and Data Science for Beginners
Latest end-to-end Learn by Coding Projects (Jupyter Notebooks) in Python and R:
All Notebooks in One Bundle: Data Science Recipes and Examples in Python & R.
End-to-End Python Machine Learning Recipes & Examples.
End-to-End R Machine Learning Recipes & Examples.
Applied Statistics with R for Beginners and Business Professionals
Data Science and Machine Learning Projects in Python: Tabular Data Analytics
Data Science and Machine Learning Projects in R: Tabular Data Analytics
Python Machine Learning & Data Science Recipes: Learn by Coding
R Machine Learning & Data Science Recipes: Learn by Coding
Comparing Different Machine Learning Algorithms in Python for Classification (FREE)
There are 2000+ End-to-End Python & R Notebooks are available to build Professional Portfolio as a Data Scientist and/or Machine Learning Specialist. All Notebooks are only $29.95. We would like to request you to have a look at the website for FREE the end-to-end notebooks, and then decide whether you would like to purchase or not.