Home » excel » Calculating majority-value in Excel

Calculating majority-value in Excel

Posted by: admin April 23, 2020 Leave a comment


I’m using the Majority Judgment voting system and need to calculate what is called a “majority-value” in Excel so I can rank the candidates.

For those unfamiliar with Majority Judgment, I will try to concisely explain. In the examples below, assume a system where voters assign each candidate one of four scores: 0, 1, 2, or 3 with 0 being the worst and 3 being the best. I’ll start with explaining “majority-grade”, which is needed to calculate a majority-value.

Majority-grade: This is essentially the “floor”ed median of all the voters’ scores for a specific candidate. If there is an odd number of voters, it’s just the median and could be calculated MEDIAN(C27:F27). If there is an even number of voters, then it’s the lower of the two middle values. So if there were four voters and a candidate got scores of {0, 1, 2, 3}, then the majority grade would be 1 (not 1.5). This could be calculated as FLOOR(MEDIAN(C27:F27), 1). However, if a candidate gets scores of {0, 0, 2, 2}, then the majority grade is 0 (not 1), and in this case FLOOR(MEDIAN(C27:F27), 1) would fail. So, to calculate the majority-grade, I think the following array formula works for all cases: MAX(IF(C27:F27<=MEDIAN(C27:F27), C27:F27)).

As you might imagine, with majority-grade, there can often be ties, with many candidates having the same majority-grade. Ties are broken by calculating a “majority-value”.

Majority-value: A majority-value is the sequence of majority grades that would be calculated for a candidate if you drop one score matching their previous majority-grade at each step. So for example, assume five voters give a candidate these scores: {0, 1, 1, 2, 3}

  • First majority grade: {0, 1, 1, 2, 3} = 1
  • Second majority grade: {0, 1, 2, 3} = 1
  • Third majority grade: {0, 2, 3} = 2
  • Fourth majority grade: {0, 3} = 0
  • Fifth majority grade: {3} = 3

The majority-value would be 1.1203, and would be sortable to produce an ordered list of candidates.

To simplify things, I will know how many voters there are and can set up a column for each majority grade and then concatenate them together.

What I think I need is to figure out how to calculate an array to use as input for a function that is another array minus a single element that matches a calculated value.

Can this be done with formulas and not VBA?

How to&Answers:

I was able to make a non-VBA solution for this problem. Here’s how to do it:

First, sort the scores. Then, we can build a majority value based on a pattern using formulas.

For example, for your list of scores: { 0, 1, 1, 2, 3 }
Since this list is sorted the majority value can be found by concatenating elements based on their position in the array (this is where the sort really helps us). In this case the pattern looks like this (numbers represent position in array): 3, 2, 4, 1, 5

Element 3: 1

Element 2: 1

Element 4: 2

Element 1: 0

Element 5: 3

See a pattern? It’s like taking one of those IQ tests online. Starting with the third element a pattern emerges: we are either subtracting or adding 1 to the element appearing two elements ago. This pattern reverses when the total number of elements are either odd or even.

To determine the first two elements we have to do some pre-calculating. The first element is simply in the middle. If it’s an even amount of scores then it’s the middle minus one. The second element is either +1 or -1 from the first element depending on if the number of scores is odd or even. Then starting with the third element our pattern begins. We look at two element behind and it is either +1 or -1, again, depending on if the data set is odd/even.

Let’s say column B4:B13 are your scores. We first determine if the set has an odd or even amount of elements in it:

Cell D2: =IF(MOD(COUNT($B$4:$B$13),2)=0,1,-1)

Then we start building our indexes:

Cell C4: =CEILING(COUNT($B$4:$B$13)/2,1)

This gives us our middle element index. This will be the first digit in the majority value.

Cell C5: =C4+$D$2

Adds to C4 depending on whether or not the number of values are odd even.

Cell C6: =C4-$D$2

Reversal of what C5 does. This gives us three full indexes to start our pattern.

C7: =C5+$D$2

C8: =C6-$D$2

Now we continue this pattern through the whole data set.

We can then take the resulting indexes and plug them into an INDEX function.

D4 looks like this: =INDEX($B$4:$B$13,C4,1)

Drag this formula down. This gives us the scores themselves in the order we need to make our majority value.

Then, finally, we concatenate all these together in and convert to a value in another cell to get our majority value:

D14: =VALUE(D4&"."&D5&D6&D7&D8&D9&D10&D11&D12&D13)

I have shared a folder for you with the Excel sheet I used to solve this problem.

We can this a step further and combine columns C and D into one formula. I separated them for clarity.


I have provided a working example of the 5 vote system you talk about since you specified that you know the number of voters. I have updated the Excel sheet in my drive that is linked above.


Majority Value formula ended up being

Where G4:G8 is a SORTED set of scores for a candidate.

And P4 is =CEILING(COUNT(G$4:G$8)/2,1)

And P5 is =P4+$P$2

And P6 is =P4-$P$2

And P7 is =P5+$P$2

And P8 is =P6-$P$2

And P2 is =IF(MOD(COUNT($G$4:$G$8),2)=0,1,-1)

Hope this makes it more clear.