Complicated (for me) countifs function

jason2023

New Member
Joined
Aug 25, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Long time visitor, first time poster. I have found stuff on this forum to be incredibly useful. However on this occasion I am either doing things completely the wrong way or just looking for the wrong thing, so I cannot figure this one out.

We have a planner as such, which identifies when people are on holiday (HOL), working from home (WFH), offsite at customers etc (OSI). The working from home is supposed to be on a random pattern and not on a regular day etc, but I have no intention of closely managing this. However a quick glance over a month by month view of the total days people are at home with give me a clue. ie if they are off every Friday, there's a pattern. Its going to be crude, but it will give me something to defend the department with.

Anyway, i have created a formula that works something like this:
1. Looks at the user row for the value WFH.
2. Looks at the top row for the day (ie Mon/Tue..etc)
3. Sums the values.

This works fine for user 1. But if I copy down to user 2 I get a REF! error and I cannot figure out why.
This is my formula:
=COUNTIFS(JUN!$B$3:$AE$3,"WFH",INDEX(JUN!$B$2:$AE$2,MATCH($A3,JUN!$A$3:$A$33,0),0),G$2)

For info I have monthly tabs, so the goal is to set it up such that it looks at each individual tab.

I would appreciate your thoughts!

Many thanks,
Jason
 

Attachments

  • 2023-08-25_12h31_23.png
    2023-08-25_12h31_23.png
    19.5 KB · Views: 9
  • 2023-08-25_12h31_41.png
    2023-08-25_12h31_41.png
    12.7 KB · Views: 8

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi & welcome to MrExcel..
Try
Excel Formula:
=COUNTIFS(JUN!$B3:$AE3,"WFH",JUN!$B$2:$AE$2,G$2)
 
Upvote 0
Hi & welcome to MrExcel..
Try
Excel Formula:
=COUNTIFS(JUN!$B3:$AE3,"WFH",JUN!$B$2:$AE$2,G$2)
That seems to work, provided that the data per user is in the same row.
In different work sheets, that may change, as users are added and removed (there are names in here in place of User 1 User 2 etc).
This was the reason behind using the MATCH function...looking back I have not explained this very well.
 
Upvote 0
Ok, how about
Excel Formula:
=COUNTIFS(INDEX(JUN!$B$3:$AE$33,MATCH($A3,JUN!$A$3:$A$33,0),),"WFH",JUN!$B$2:$AE$2,G$2)
 
Upvote 0
Ok, how about
Excel Formula:
=COUNTIFS(INDEX(JUN!$B$3:$AE$33,MATCH($A3,JUN!$A$3:$A$33,0),),"WFH",JUN!$B$2:$AE$2,G$2)
That's great! Works perfectly!
Now to understand it.....I think I had some of the right bits, just in the wrong order.

The INDEX function is finding ANY location which meets with the USER (column A), which contains WFH.
I guess the problem was I wasn't using the INDEX function on that search criteria.
 
Upvote 0
The index/match is finding the row that matches the user.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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