Having used the MrExcel forums for plenty of excel help over the past months, I have finally found something that google searches don't seem to provide answers for. So, here goes.
I have a set of data that is based off of a business number. Multiple instances of the same business number can appear in the table if the business has multiple locations. I am trying to calculate hours of operation outside of a specific window based on the hours given and the frequency of those hours (once a month, bi-weekly, weekly, etc). I have a separate table for these calculations and I've already used MAXIF and MINIF to find the best open/close hours. I had used a complicated set of if, index, and vlookup functions to find appropriate data based on whether an office becomes closed. However, the limit of this complicated mess has been reached.
I already have assigned numeric values to the 5 options in my frequency columns: "" = 0, "Closed" = 0, "monthly" = 1, "bi-weekly" = 2, "weekly" = 4. What I want to do is have a max function that looks up all instances of a business number, finds the maximum value of the frequency (based on the lookup table I created) and then prints the specific text into my calculation table.
example:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]office #[/TD]
[TD]address[/TD]
[TD]mon open[/TD]
[TD]mon close[/TD]
[TD]mon freq[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]123 fake[/TD]
[TD]9:00 AM[/TD]
[TD]8:00 PM[/TD]
[TD]monthly[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]456 fake[/TD]
[TD]7:00 AM[/TD]
[TD]5:00 PM[/TD]
[TD]bi-weekly[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]789 fake[/TD]
[TD]Closed[/TD]
[TD]Closed[/TD]
[TD]Closed[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]still fake[/TD]
[TD]9:00 AM[/TD]
[TD]6:00 PM[/TD]
[TD]weekly[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]Closed[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]monthly[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]bi-weekly[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]weekly[/TD]
[TD]4[/TD]
[/TR]
</tbody>[/TABLE]
Note: the blank cell is indeed blank, or "".
I can correctly get 7:00 AM as the earliest open, I can correctly find 8:00 PM as the latest close. I cannot correctly select "weekly" as the MAX text option based on its assigned value of 4. I know this will need to be an array formula, but I simply cannot construct a formula based on the logic in my head. Any help would be greatly appreciated.
p.s. Yes, I realize that the 7:00 AM open time should theoretically be paired with a bi-weekly value of 2, but that simply isn't how we calculate things. We take earliest open, earliest close, and best frequency to calculate hours.
I have a set of data that is based off of a business number. Multiple instances of the same business number can appear in the table if the business has multiple locations. I am trying to calculate hours of operation outside of a specific window based on the hours given and the frequency of those hours (once a month, bi-weekly, weekly, etc). I have a separate table for these calculations and I've already used MAXIF and MINIF to find the best open/close hours. I had used a complicated set of if, index, and vlookup functions to find appropriate data based on whether an office becomes closed. However, the limit of this complicated mess has been reached.
I already have assigned numeric values to the 5 options in my frequency columns: "" = 0, "Closed" = 0, "monthly" = 1, "bi-weekly" = 2, "weekly" = 4. What I want to do is have a max function that looks up all instances of a business number, finds the maximum value of the frequency (based on the lookup table I created) and then prints the specific text into my calculation table.
example:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]office #[/TD]
[TD]address[/TD]
[TD]mon open[/TD]
[TD]mon close[/TD]
[TD]mon freq[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]123 fake[/TD]
[TD]9:00 AM[/TD]
[TD]8:00 PM[/TD]
[TD]monthly[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]456 fake[/TD]
[TD]7:00 AM[/TD]
[TD]5:00 PM[/TD]
[TD]bi-weekly[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]789 fake[/TD]
[TD]Closed[/TD]
[TD]Closed[/TD]
[TD]Closed[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]still fake[/TD]
[TD]9:00 AM[/TD]
[TD]6:00 PM[/TD]
[TD]weekly[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]Closed[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]monthly[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]bi-weekly[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]weekly[/TD]
[TD]4[/TD]
[/TR]
</tbody>[/TABLE]
Note: the blank cell is indeed blank, or "".
I can correctly get 7:00 AM as the earliest open, I can correctly find 8:00 PM as the latest close. I cannot correctly select "weekly" as the MAX text option based on its assigned value of 4. I know this will need to be an array formula, but I simply cannot construct a formula based on the logic in my head. Any help would be greatly appreciated.
p.s. Yes, I realize that the 7:00 AM open time should theoretically be paired with a bi-weekly value of 2, but that simply isn't how we calculate things. We take earliest open, earliest close, and best frequency to calculate hours.