Excel: Using a formula (no VBA) how to check if elements in a range are in another array which is defined by index/match - arrays

I'd have another question. The situation is as follows: I have two tables (=formatted Excel tables). The situation looks as below. I am trying to filter for the $ sales amount (cell E4) of a given sales rep (cell D4). I was thinking about using =SUMPRODUCT(IF((Table2[Store ID]=INDEX(Table1[Store ID],MATCH("Marc",Table1[Sales Rep],0),)),1,0)) (as I would have other conditions such as month which are no displayed in my example below), however, that's not giving me the correct value. The index-formula gives me just the first result once it finds "Marc".
The "correct" result in the example shown would be $121 as Marc accounts for these sales in the store with ID 1.
How can I overcome this problem? Any help would be much appreciated.

Add an additional column [shop ok] with a formula =IF(F7=$D$4,[#[store ID]],0) into Table1, to indicate that this store is under Marc's control.
In E4 insert a formula
=SUMPRODUCT(Table2[Sales]* COUNTIF(Table1[shop ok],Table2[Store ID]))
It's an array formula, so add it using Ctrl+Shift+Enter
didn't manage to avoid adding additional columns, got some errors, so ended up with this solution for now.

In E4, enter formula :
=SUMPRODUCT(SUMIFS(I7:I9,H7:H9,D7:D9)*(F7:F9=D4))

Related

How do I change my multi criteria Index Match formula in such a way that it sorts results closest to today?

How can do I write an array formula in such a way that both following factors apply:
Results give me the names of sales that have either TRUE OR FALSE next to it in a different column/sheet.
Results are sorted chronologically based on the date that is connected to each sale. Each sale has a different date next to it. This can be found in the same sheet as where the "TRUE OR FALSE" result is displayed. Column with the dates is called "AY:AY". I use an indirect formula to target the correct sheet within the spreadsheet.
I currently only have the first criteria implemented, don't know how to do the 2nd one.
Since the raw data is not ordered I need this to happen when I use the Index Match Array formula. So far I have this formula in my Google Sheets spreadsheet.
=ArrayFormula(iferror(index(indirect("'"&$B$5&" 2023'!c:c");small(if(TRUE=indirect("'"&$B$5&" 2023'!ca:ca");row(indirect("'"&$B$5&" 2023'!ca:ca"))-row(indirect("'"&$B$5&" 2023'!$ca$1"))+1);row(1:1)));""))
I know I could use the Index Array formula below with multiple criteria, but don't know how to implement the date component.
INDEX(indirect("'"&$B$5&" 2023'!c:c");SMALL(IF(COUNTIF(_______)*COUNTIF("true"; indirect("'"&$B$5&" 2023'!CA:CA"); ROW(indirect("'"&$B$5&" 2023'!A:CA"))-MIN(ROW(indirect("'"&$B$5&" 2023'!A:CA"))+1); ROW(indirect("'"&$B$5&" 2023'!A1));COLUMN(indirect("'"&$B$5&" 2023'!A1))
Thanks in advance.
A query like this could help?
=QUERY(INDIRECT("'"&$B$5&" 2023'!C:CA"),"SELECT C,AY WHERE CA = TRUE order by AY")

Filtering Values Produced by an ARRAYFORMULA

I am using an ARRAYFORMULA to extract unique values from a list of names and total up a second column for each of those names.
Here is some example data and the ARRAYFORMULA I am using
Example Data
ARRAYFORMULA in cell E3
=ARRAYFORMULA({{unique(B3:B11)},{sumif(B3:B11, (unique(B3:B11)),C3:C11)}})
What I would like to do is filter out those names where the total number of tokens is zero - i.e. I would like Peter to be filtered out of the list because he has a net total of zero Tokens.
[I'd also like to have Peter, and any others, displayed in a separate list, but I guess if you can help me crack this first part I can help myself crack the second part]
Is there a way I can achieve what I want with a single ARRAYFORMULA? Is there another (better) way to achieve the same result?
I've bashed my head against this for a while so would be grateful for any help
use:
=QUERY(QUERY({B3:C};
"select Col1,sum(Col2)
where Col1 is not null
group by Col1
label sum(Col1)''");
"where Col2 is not null"; )
Query and Filter
=FILTER(QUERY(A2:B10,"select A, SUM(B) group by A"),QUERY(A2:B10,"select SUM(B) group by A") > 0)
You don't need an array formula. The FILTER on the outside of the QUERY takes care of our zero token problem. And the QUERY selects column A and SUM of B and returns the proper names and sums, so that there are no repeating names. We need a second identical QUERY for the FILTER to compare 0s against, Because our QUERY doesn't exist outside of the formula. Every reference you make to the QUERY requires you to perform the QUERY again.

How to use COUNTIFS based on multiple criteria over different sized ranges?

I have an attendance tracker in which I'm trying to account for each employee type per day.
I have a summary page (sheet1) in which I want the count of each type (A,B,C,D,E) based on the day in cell C2 whether or not they have an X on sheet2 for that day.
Using =COUNTIF(FILTER(Sheet2!$A$5:$GG$969,Sheet2!$A$5:$GG$5=$C$2),"X") I am able to get a total of "X" based on the date in cell C2.
However, I'm having trouble getting the formula to work counting each employee type.
=COUNTIFS(Sheet2!A5:AM31,A7,(FILTER(Sheet2!A5:AM31=C2)),"X")
This gives me an error "Array arguments to COUNTIFS are of different size."
I'm not sure how else to configure this. Below is a link to my sample sheet:
Appreciate any help!
https://docs.google.com/spreadsheets/d/1OdJTwbFsNcR1hO1qzMBGUY4iXcWgDwIAJmBAVE9cs0k/edit?usp=sharing
I think this would work, dragged down for the other groups.
=COUNTIFS(Sheet2!A$6:A$31,A7,FILTER(Sheet2!$6:$31,Sheet2!$5:$5=C$2),"X")
However, I would encourage you to look at this sample sheet (a copy of yours) where I've added a new tab called MK.Help, designed to be hidden, but used as a sort of helper tab to make all sorts of things you might like to do easier. Including the count you asked about.
It has one single formula in cell A2 where you can see what it does.
=ARRAYFORMULA(QUERY(SPLIT(FLATTEN(Sheet2!C5:5&"|"&Sheet2!A6:A31&"|"&Sheet2!B6:B31&"|"&Sheet2!C6:31),"|",0,0),"where Col3<>'' order by Col1"))
try:
={"", ""; QUERY(FILTER(Sheet2!A6:A31, FILTER(Sheet2!6:31, Sheet2!5:5=C2)="X"),
"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1)''");
"Total", COUNTA(IFNA(FILTER(Sheet2!A6:A31, FILTER(Sheet2!6:31, Sheet2!5:5=C2)="X")))}

EXCEL: Create Array Formula out of INDEX/MATCH with multiple results

my aim is to convert a massive excel sheet with different projects, employees and hours worked per month into an overview per employee. It should be possible to display the projects the employee is involved in and how many hours he worked per project per month.
The original sheet looks something like this:
I managed to find the projects Person A worked in by filtering through the INDEX/MATCH function. I applied the formula to the whole row where the employees are listed and receive multiple results of projects. My question is how to transform the formula into something more effective to copy all of the matched results (projects) into a column (see 1).
This is what I have so far, if matches the employee name in a certain area; the output is the first match of the project he is involved in:
=INDEX(B2:J3;1;MATCH("Person A";Sheet1!B3:E3;0))
How can I copy this to the bottom cells to copy all of the matched results? Does it help to create an array formula with this?
You can use he following formula in cell B9:
=IFERROR(INDEX($2:$2,SMALL(IF($3:$3=$B$8,COLUMN($3:$3)-COLUMN(INDEX($3:$3,1,1))+1),ROWS(A$1:A1))),"")
It indexes row 2 and looks for the column number of the first match in row 3 that equals the value in B8 (=Person A). When dragging down it will look for the second match ROWS(A$1:A1) will become ROWS(A$1:A2) = 2.
For Person B you can use this formula in cell B14:
=IFERROR(INDEX($2:$2,SMALL(IF($3:$3=$B$13,COLUMN($3:$3)-COLUMN(INDEX($3:$3,1,1))+1),ROWS(A$1:A1))),"")
I hope this is what you where looking for.
PS
if you paste the following formula in cell C9 you will get the sum result for Person A on Project XY in month 10 2019:
=IF(OR($B9="",C$8=""),"",SUMPRODUCT(($B$2:$K$2=$B9)*($B$3:$K$3=$B$8)*($A$4:$A$6=C$8),B4:K6))
Note: That is provided that the value in cell C8 equals the value in cell A4.

Vlookup from multiple criteria to display nearest answer

I was hoping someone can help me. I have hit a solid wall.
I have a table with product information included and I am building a calculator which should spit out a number of options based on set criteria which is in the table. I am failing at just pulling through a code. I feel rather embarassed asking about how to do a vlookup here. But basically I have a vlookup which depends on multiple criteria and for the calc to cough out the nearest match (if applicable) based on this criteria.
Criteria 1 = Product
Criteria 2 = Type
Criteria 3 = Height
Criteria 4 = Min
I have created a search key in the table to concatenate all of these columns and then done a vlookup, which is =Vlookup(Criteria1 & Criteria2 & Criteria3 & Criteria4, Table Data, Code Required) But this does not appear to be giving me results, it either coughs out an error or the incorrect product. Below is my data and my calc I am hoping to complete. Can someone please help?
Here is an example looking for a closest match on Min. It demonstrates the principle so you can extend.
The closest match formula part is:
MATCH(MIN(ABS(E2:E4-K2)),ABS(E2:E4-K2),0))
Column E for column with Min values in. And K2 for target Min. This is an array formula entered with Ctrl + Shift+Enter. You would adjust the range of E2:E4.
The multiple criteria part is using:
=MATCH(lookup_value_1&lookup_value_2&lookup_value_3, lookup_array_1&lookup_array_2&lookup_array_3, match_type)
Where you are concantenating your parameters and searching for a match of the concatenation of those parameters in the table (you could do this against the key column if the key is made up of the same parameters.)
Overall formula with some test data (using one estimate figure):
=INDEX(F:F,MATCH(K1&K5&J5&INDEX(E2:E4,MATCH(MIN(ABS(E2:E4-K2)),ABS(E2:E4-K2),0)),B:B&C:C&D:D&E:E,0))
Above entered combined formula remember is an array formula so entered with Ctrl+Shift+Enter . You can reduce the ranges from entire columns to only those rows holding data.
Data data:
I am not typing all that out from picture so here is a quick n dirty
I tried with the QHarr's solution but it didn't work with all the rows.
My solution is:
Add a column with:
=IF(E2 < $K$2, E2, 0) and copy for all rows
In L5 create the formula:
{=INDEX(F2:F19,MATCH($K$1&K5&$J$5&INDEX(E2:E19,MATCH(MAX(SI(B2:B19=$K$1,1,0)*IF(C2:C19=K5,1,0)*IF(D2:D19=$J$5,1,0)*G2:G19,0),E2:E19,0)),B2:B19&C2:C19&D2:D19&E2:E19,0))}
Copy the formula to L6 and L7
Excel exercise printscreen
Originally marked this as answered and it did work initially but as I added more products it began to fail. I did manage to (after much trial and error) find a simple solution {=INDEX(Calc!$I$2:$I$189,MATCH(Output!$H$7,IF(Calc!$B$2:$B$189=Output!A12,Calc!$H$2:$H$189),1))}

Resources