Find mode of dynamic array

himperson1

New Member
Joined
Jun 23, 2016
Messages
33
Hello. I'm looking for some help with the following:

I need to find the mode of an array that changes based on the day of the month and which shift im looking at.

Ex:

Day111222333
Shift123123123
LevelEmptyMinMinMaxMinMaxEmptyMaxMax

<tbody>
</tbody>


If I wanted to find the mode of 1st shift until the 3rd of the month, the output result is "Empty"
The array it is looking at would be {Empty, 0, 0, Max, 0, 0, Empty, 0, 0}

If I wanted to find the mode of 2nd shift until the 2nd of the month, the output result is "Min"
The array it is looking at would be {0, Min, 0, 0, Min, 0}



I have found the following code to potentially use, but I am having difficulties making it fit my spreadsheet.
Code:
= INDEX(rng,MODE(IF(rng<>"",MATCH(rng,rng,0))))

I use the following code elsewhere in my spreadsheet to find the sum of a similar array
Code:
=SUMPRODUCT(--(MOD(COLUMN(INDIRECT("'MS'!E"&MS!$A$35&":"&A$1&MS!$A$35))-COLUMN(INDIRECT("'MS'!E"&MS!$A$35))+1,3)=1),INDIRECT("'MS'!E"&MS!$A$35&":"&A$1&MS!$A$35))

Thank you
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try...

A1:N3

Day111222333ShiftDayMode
Shift12312312313Empty
LevelEmptyMinMinMaxMinMaxEmptyMaxMax

<tbody>
</tbody>

N2, confirmed with CONTROL+SHIFT+ENTER:

=INDEX(B3:J3,MODE(IF(B1:J1<=M2,IF(B2:J2=L2,IF(LEN(B3:J3)>0,MATCH(B3:J3,B3:J3,0))))))

Hope this helps!
 
Upvote 0
This is close!

The one detail that I've forgotten is that the shift is never actually picked.
I have separate columns for each display of data.

Ex: N2 data for shift 1 always appears in L3. N2 data for shift 2 always appears in M3. etc.
 
Upvote 0
Is this what you mean?

A1:N3

Day111222333Day
Shift1231231233
LevelEmptyMinMinMaxMinMaxEmptyMaxMaxEmptyMin. . .

<tbody>
</tbody>

L3, confirmed with CONTROL+SHIFT+ENTER:

=INDEX($B3:$J3,MODE(IF($B$1:$J$1<=$L$2,IF($B$2:$J$2=1,IF(LEN($B3:$J3)>0,MATCH($B3:$J3,$B3:$J3,0))))))

M3, confirmed with CONTROL+SHIFT+ENTER:

=INDEX($B3:$J3,MODE(IF($B$1:$J$1<=$L$2,IF($B$2:$J$2=2,IF(LEN($B3:$J3)>0,MATCH($B3:$J3,$B3:$J3,0))))))

Alternatively, you can use a single formula...

L3, confirmed with CONTROL+SHIFT+ENTER, and copied across:

=INDEX($B3:$J3,MODE(IF($B$1:$J$1<=$L$2,IF($B$2:$J$2=COLUMNS($L3:L3),IF(LEN($B3:$J3)>0,MATCH($B3:$J3,$B3:$J3,0))))))

If this is not what you mean, please post a sample of the expected results based on the data you provided.
 
Upvote 0

Forum statistics

Threads
1,215,424
Messages
6,124,817
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top