Shorten these Or conditions

mahmed1

Well-known Member
Joined
Mar 28, 2009
Messages
2,302
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi All,

How can I shorten these 2 formulas

VBA Code:
=IF(OR([@[Team Manager]]="Matt Gritton Team Blue2000",[@[Team Manager]]="Matt Gritton Team Green2000",[@[Team Manager]]="Academy2000"),"CS_ACADEMY",IF(OR([@[Team Manager]]="Matt Gritton Team Blue2001",[@[Team Manager]]="Matt Gritton Team Green2001",[@[Team Manager]]="Academy2001"),"CS_ACADEMY",IF(OR([@[Team Manager]]="Matt Gritton Team Blue2003",[@[Team Manager]]="Matt Gritton Team Green2003",[@[Team Manager]]="Academy2003"),"CS_ACADEMY",IF(OR([@[Team Manager]]="Matt Gritton Team Blue4000",[@[Team Manager]]="Matt Gritton Team Green4000",[@[Team Manager]]="Academy4000"),"COSC_ACADEMY",[@[Team Manager]]))))


VBA Code:
=IFERROR(SUMPRODUCT(--(tbl_Agent_Results[AHT]),--(tbl_Agent_Results[contactsHandled]),--(tbl_Agent_Results[Date_]=I$5),(--(tbl_Agent_Results[Team Manager]="MATT GRITTON TEAM GREEN4000")+--(tbl_Agent_Results[Team Manager]="MATT GRITTON TEAM BLUE4000")+--(tbl_Agent_Results[Team Manager]="Academy4000")))/SUMPRODUCT(--(tbl_Agent_Results[contactsHandled]),--(tbl_Agent_Results[Date_]=I$5),(--(tbl_Agent_Results[Team Manager]="MATT GRITTON TEAM GREEN4000")+--(tbl_Agent_Results[Team Manager]="MATT GRITTON TEAM BLUE4000")+--(tbl_Agent_Results[Team Manager]="Academy4000"))),"")

I have the same multiple or conditions and was hoping I can make this slicker and more easier to condense it down as the condition could grow

Many Thanks
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi All,

How can I shorten these 2 formulas

VBA Code:
=IF(OR([@[Team Manager]]="Matt Gritton Team Blue2000",[@[Team Manager]]="Matt Gritton Team Green2000",[@[Team Manager]]="Academy2000"),"CS_ACADEMY",IF(OR([@[Team Manager]]="Matt Gritton Team Blue2001",[@[Team Manager]]="Matt Gritton Team Green2001",[@[Team Manager]]="Academy2001"),"CS_ACADEMY",IF(OR([@[Team Manager]]="Matt Gritton Team Blue2003",[@[Team Manager]]="Matt Gritton Team Green2003",[@[Team Manager]]="Academy2003"),"CS_ACADEMY",IF(OR([@[Team Manager]]="Matt Gritton Team Blue4000",[@[Team Manager]]="Matt Gritton Team Green4000",[@[Team Manager]]="Academy4000"),"COSC_ACADEMY",[@[Team Manager]]))))


VBA Code:
=IFERROR(SUMPRODUCT(--(tbl_Agent_Results[AHT]),--(tbl_Agent_Results[contactsHandled]),--(tbl_Agent_Results[Date_]=I$5),(--(tbl_Agent_Results[Team Manager]="MATT GRITTON TEAM GREEN4000")+--(tbl_Agent_Results[Team Manager]="MATT GRITTON TEAM BLUE4000")+--(tbl_Agent_Results[Team Manager]="Academy4000")))/SUMPRODUCT(--(tbl_Agent_Results[contactsHandled]),--(tbl_Agent_Results[Date_]=I$5),(--(tbl_Agent_Results[Team Manager]="MATT GRITTON TEAM GREEN4000")+--(tbl_Agent_Results[Team Manager]="MATT GRITTON TEAM BLUE4000")+--(tbl_Agent_Results[Team Manager]="Academy4000"))),"")

I have the same multiple or conditions and was hoping I can make this slicker and more easier to condense it down as the condition could grow

Many Thanks
I tried to create 2 named range and use that for the 1st formula with no luck

CS_Academy_List

Matt Gritton Team Blue2000
Matt Gritton Team Green2000 etc....

COSC_Academy_List

Matt Gritton Team Blue4000
Matt Gritton Team Green4000 etc....

=IF([@[Team Manager]]= CS_Academy_List, “CS_Academy”, IF([@[Team Manager]]= COSC_Academy_List,”COSC_Academy, [@[Team Manager]]))

I tried 2 do same with sumproduct but failed that too :(
=IFERROR(SUMPRODUCT(--(tbl_Agent_Results[AHT]),--(tbl_Agent_Results[contactsHandled]),--(tbl_Agent_Results[Date_]=I$5),- -(tbl_Agent_Results[Team Manager]= COSC_Academy_List)) /SUMPRODUCT(--(tbl_Agent_Results[contactsHandled]),--(tbl_Agent_Results[Date_]=I$5),
--(tbl_Agent_Results[Team Manager]=“COSC_Academy”)),””)
 
Upvote 0
I tried to wrap in count ifs and sum ifs but can’t get it to work
 
Upvote 0
I tried this too for the 1st formula

=If(Countifs(CS_Academy_List,[@[Team Manager]])>0,”CS_Academy”, If(Countifs(COSC_Academy_List,[@[Team Manager]])>0,”COSC_Academy”,[@[Team Manager]]))

no clue how to incorporate this sumifs into the sum product to make it smaller and more dynamic
 
Upvote 0
Any formula gurus who can help me

thank you so much

much appreciated
 
Upvote 0
My attempts of shortening both formulas without having much luck

The reason why i want to make it dynamic is because my or criteria could extend


VBA Code:
=If(Countifs(CS_Academy_List,[@[Team Manager]])>0,”CS_Academy”, If(Countifs(COSC_Academy_List,[@[Team Manager]])>0,”COSC_Academy”,[@[Team Manager]]))
VBA Code:
=IFERROR(SUMPRODUCT(- -(tbl_Agent_Results[AHT]),--(tbl_Agent_Results[contactsHandled]),--(tbl_Agent_Results[Date_]=I$5), ISNUMBER(MATCH(tbl_Agent_Results[Team Manager],COSC_Academy_List)))
/
SUMPRODUCT(--(tbl_Agent_Results[contactsHandled]),--(tbl_Agent_Results[Date_]=I$5),
ISNUMBER(MATCH(tbl_Agent_Results[Team Manager],COSC_Academy_List))),””)
 
Upvote 0
Another attempt




=IFERROR(SUMPRODUCT(- -(tbl_Agent_Results[AHT]),--(tbl_Agent_Results[contactsHandled]),--(tbl_Agent_Results[Date_]=I$5),countifs([Team Manager],COSC_Academy_List))
/
SUMPRODUCT(--(tbl_Agent_Results[contactsHandled]),--(tbl_Agent_Results[Date_]=I$5),countifs([Team Manager],COSC_Academy_List)),””)
 
Upvote 0
i don't use structured references so this syntax might be off, but you could use ISNUMBER(MATCH(@[Team Manager], someRange,0)) to see if the team manager is in the list located at someRange.
 
Upvote 0
i don't use structured references so this syntax might be off, but you could use ISNUMBER(MATCH(@[Team Manager], someRange,0)) to see if the team manager is in the list located at someRange.
Firstly I want to thank u so much for responding back to me - I appreciate it so much

based on the formula you have given - would you say i need to amend to something like this (ive not tested yet)


=IFERROR(SUMPRODUCT(- -(tbl_Agent_Results[AHT]),--(tbl_Agent_Results[contactsHandled]),--(tbl_Agent_Results[Date_]=I$5), ISNUMBER(MATCH(@[Team Manager],COSC_Academy_List,0)))
/
SUMPRODUCT(--(tbl_Agent_Results[contactsHandled]),--(tbl_Agent_Results[Date_]=I$5),
ISNUMBER(MATCH(@[Team Manager], COSC_Academy_List,0))),””)

only thing i can see is that its only looking at 1 cell where as i need to check team manager column to see if it exists with in the list range

il give it a go
 
Upvote 0

Forum statistics

Threads
1,215,521
Messages
6,125,305
Members
449,218
Latest member
Excel Master

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