# Need help combining Countifs with sumproduct

1. ## Need help combining Countifs with sumproduct

This is my first post so first of all, wanted to say Hello to everyone.
Now I am working on a Google spreadsheet and have several tabs with names in column A so I made column A dynamic and as soon as I add a name of a tab in column A1 it should check 4 conditions in that tab

1. Check Column L and see if we have "Track-LPH12"
2. Check Column AG and see if we have Either "Waiting, Valid or Invalid"
3. Check Column Q and see if there is any thing (notes)
4. Check Column X and see if there is any thing (sub notes)

ARRAYFORMULA(IF(\$A1="",,COUNTIFS(INDIRECT(\$A1&"!\$L:\$L"),"Track-LPH12",INDIRECT(\$A1&"!\$AG:\$AG"),"Waiting",INDIRECT(\$A1&"!\$Q:\$Q"),"*",INDIRECT(\$A1&"!\$X:\$X"),"*")+COUNTIFS(INDIRECT(\$A1&"!\$L:\$L"),"Track-LPH12",INDIRECT(\$A1&"!\$AG:\$AG"),"Valid",INDIRECT(\$A1&"!\$Q:\$Q"),"*",INDIRECT(\$A1&"!\$X:\$X"),"*")+COUNTIFS(INDIRECT(\$A1&"!\$L:\$L"),"Track-LPH12",INDIRECT(\$A1&"!\$AG:\$AG"),"Invalid",INDIRECT(\$A1&"!\$Q:\$Q"),"*",INDIRECT(\$A1&"!\$X:\$X"),"*")))

Now the given formula works fine but if you see we have 3 conditions (Point 1, 3 and 4) which are same for all and only condition 2 changes "Waiting, Valid or Invalid", so I have to write full formula for 'Waiting' + same formula for 'Valid' and 'Invalid'

COUNTIFS(INDIRECT(\$A1&"!\$L:\$L"),"Track-LPH12",INDIRECT(\$A1&"!\$AG:\$AG"),"Waiting",INDIRECT(\$A1&"!\$Q:\$Q"),"*",INDIRECT(\$A1&"!\$X:\$X"),"*")+
COUNTIFS(INDIRECT(\$A1&"!\$L:\$L"),"Track-LPH12",INDIRECT(\$A1&"!\$AG:\$AG"),"Valid",INDIRECT(\$A1&"!\$Q:\$Q"),"*",INDIRECT(\$A1&"!\$X:\$X"),"*")+
COUNTIFS(INDIRECT(\$A1&"!\$L:\$L"),"Track-LPH12",INDIRECT(\$A1&"!\$AG:\$AG"),"Invalid",INDIRECT(\$A1&"!\$Q:\$Q"),"*",INDIRECT(\$A1&"!\$X:\$X"),"*")))

Is there a way that we can combine "Waiting, Valid or Invalid" instead of writing individual formula for each and then add them one by one, I am thinking to add 2~3 more data set for condition 2 so the formula will become too big and prone to errors.

I think there is a way to use sumproduct along with countifs but, can't make it work.

Thanks

2. ## Re: Need help combining Countifs with sumproduct

Welcome to the forum!¬

3. ## Re: Need help combining Countifs with sumproduct

It won't be any more efficient but, yes, you can shorten the syntax:

Formula:
`Please Login or Register  to view this content.`

FWIW, I'd suggest two things;

1 - avoid use of entire column references if you can, even with COUNTIFS -- but particularly when used in Volatile context like the above {given INDIRECT}
2 - you may want to use ?* rather than * for you "any note" search as * would find a Null string ("") for ex. where as ?* would not (must be 1 char)

on an aside, in reference to point 1 above, I would advise against using SUMPRODUCT alternatives (where you would use + to conduct an OR based test)

4. ## Re: Need help combining Countifs with sumproduct

Thanks AliGW for warm welcome and moving to the correct section

XLent Thanks a lot for such a quick reply and noted about your suggestions
Regarding the formula as you can see in screenshot below, Its not counting all the 3 conditions ("Waiting","Valid","Invalid") where as its only counting first entry "Waiting"

From the Screenshot you can see row no. 9 "Aleksander" Column D, E and F have individual values and in column P where I put the new formula it only show Value 85 which matches with the data for Waiting where as its not adding up data for Valid and Invalid. Same goes for next column "Alex".

P.S. I am not allowed to post any picture or link so please advice how can i post a screenshot to show what are those columns stands for

5. ## Re: Need help combining Countifs with sumproduct

Made it to work Just used Sumproduct instead of Sum and its working perfect. Thanks everyone for the help

6. ## Re: Need help combining Countifs with sumproduct

If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

7. ## Re: Need help combining Countifs with sumproduct

Done and thanks for the help. Appreciated

##### Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1