Modifying complex formula: Adding a condition

spydey

Active Member
Joined
Sep 19, 2017
Messages
314
Office Version
  1. 2013
Platform
  1. Windows
A while back, I received some phenomenal help from @Nishant94 regarding a complex formula I was trying to build to capture unique number of overlap days based upon some criteria.

The original thread is here:

Count Number of Unique Overlap Days - Meeting Criteria

The formula (CSE) is this:

{=SUM(--(MMULT((ROW(INDIRECT(B2&":"&C2))>=TRANSPOSE(IF(Events!$A$2:$A$19=A2,Events!$C$2:$C$19)))*(ROW(INDIRECT(B2&":"&C2))<=TRANSPOSE(IF(Events!$A$2:$A$19=A2,Events!$D$2:$D$19))),Events!$C$2:$C$19^0)>0))}

The formula Nishant94 provided me works great.

However, now I need to modify it slightly to account for one additional criteria. I would think it should be somewhat simple based upon the criteria, but am not 100% sure I know where I should input the additional criteria in the already existing formula.

I have added an additional column (column E) to my sheet 2 (see original post) which contains either "Yes" or "No".

I only want to count the unique number of days, which the formula above does, but only for those rows where the new column has a YES in it.

I was thinking of something like:

{=SUM(--(MMULT((ROW(INDIRECT(B2&":"&C2))>=TRANSPOSE(IF(Events!$E$2:$E$19="Yes",IF(Events!$A$2:$A$19=A2,Events!$C$2:$C$19))))*(ROW(INDIRECT(B2&":"&C2))<=TRANSPOSE(IF(Events!$E$2:$E$19="Yes",IF(Events!$A$2:$A$19=A2,Events!$D$2:$D$19)))),Events!$C$2:$C$19^0)>0))}


I haven't tested it yet (going to in just a moment), but was hoping to get someone's input on if it should theoretically work or if I have my order and syntax perhaps incorrect. I am not very experienced with the MMULT function so still struggle to ensure it is aligned correctly.

Anythoughts, ideas, corrections, input, is greatly appreciated!!

-Spydey
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Actually, now that I think about it, I think that I need my formula to be the following:

{=SUM(--(MMULT((ROW(INDIRECT(B2&":"&C2))>=TRANSPOSE(IF(Events!$A$2:$A$19=A2,IF(Events!$E$2:$E$19="Yes",Events!$C$2:$C$19))))*(ROW(INDIRECT(B2&":"&C2))<=TRANSPOSE(IF(Events!$A$2:$A$19=A2,IF(Events!$E$2:$E$19="Yes",Events!$D$2:$D$19)))),Events!$C$2:$C$19^0)>0))}

That way it identifies the item first, if it is present, then if it has a Yes.

Giving this a try.

-Spydey
 
Upvote 0
Yup, that it worked!!!!

If any of you see something that maybe I missed, please let me know.

-Spydey
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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