VBA Finding Unique Distinct Values based on Multiple Dynamic Criteria - excel

It's not too easy to explain this but basically I have a data set that pulls through information to the dashboard.
I am looking to find the unique distinct amount of managers matched to 5 simultaneous criteria.
The data set looks like this:
The dashboard has an option to chose criteria to search this database with which looks like this
My Question is - Say I search the entire database for jobs by a certain Principal (using the * wildcard for all other criteria). How do I then find out the distinct number of managers and consultants working on these jobs?
Sorry I couldn't attach the figures as figures rather than a photo - not sure how to do it.

Just wanted to demonstrate how you could approuch this:
My sample data...
Formula in J1:
=SUM(--(FREQUENCY(IF((A2:A10=I1),MATCH(F2:F10,F2:F10,0)),ROW(F2:F10)-ROW(F2)+1)>0))
Formula in J2:
=SUM(--(FREQUENCY(IF((A2:A10=I1)*(B2:B10=I2),MATCH(F2:F10,F2:F10,0)),ROW(F2:F10)-ROW(F2)+1)>0))
Formula in J3:
=SUM(--(FREQUENCY(IF((A2:A10=I1)*(B2:B10=I2)*(C2:C10=I3),MATCH(F2:F10,F2:F10,0)),ROW(F2:F10)-ROW(F2)+1)>0))
All these formula need to be entered through CtrlShiftEnter
Unfortunately IF(.. doesn't support wildcards, so that's why I do it like this.
Append on this for the 4th and 5th criteria....

Related

How can I multiply lookup values from two different tables and then sum them in just one cell?

I am trying to get a dedicated material table in excel. So we have a few products and these products require particular materials. I know how much and which materials go in particular products. I also know how much is sold in which year, now I want to calculate the required materials for these years. Because the productbase is large (>100), and thus >100 columns, I would like to use some lookup or index function to automate the multiplication.
As shown in the picture, I tried using a sumproduct, which was also explained in some other question on stackoverflow. This sumproduct should multiply all values obtained in one table with the corresponding values in the other. I feel that something is not right about my first two match functions (see picture again)
The code used:
=SUMPRODUCT(INDEX($B$19:$E$22;MATCH(B$2;$A$19:$A$22;0);MATCH(B$10;$B$18:$E$18;0));INDEX($B$3:$E$5;MATCH($A11;$A$3:$A$5;0);MATCH(TRUE;$B$3:$E$5>0;0)))
The image contains some extra info and explanation of the actual need
The reason that it needs a lookup or index is because the products in table 3 are always in another order than what is shown in table 1.
I would like to have this sumproduct as automated as possible, thank you in advance:)
You could try and adapt the below:
Formula in B11:
=SUM(INDEX($B:$B,MATCH($A11,$A$1:$A$5,0)):INDEX($E:$E,MATCH($A11,$A$1:$A$5,0))*TRANSPOSE(B$19:B$22))
Entered as array, CtrlShiftEnter
Drag right and down into matrix.
Side-note: Be sure to edit your question to include all relevant information, including your own atempted formula, as text. Way easier to copy paste sample data that has been formatted as markdown :)

How to total a column in a table based on filter criteria from two other columns in excel

I have the following Table as an example:
Name Task Amount
Jennifer Sing 10
Tom Dance 15
Joe Jump 72
Mandy Scream 10
And supporting lists:
Names Tasks
Jennifer Dance
Joe Sing
Jump
I need to find the total of the sum of amounts where Name is in the Names list AND Task is in the Tasks list. In other words, if the person AND the task are in the list of relevant people and tasks, total their amount.
So, for example, the total would be 10+72=82.
I have tried to name the ranges of the criteria lists as RelevantNamesList and RelevantTasksLists, and the input table columns as Names and Tasks and Hours, and then using sumif, however I am not even able to get it to work with a single condition.
=SUMIF( Names, ( -- ( ISTEXT(VLOOKUP( Names, RelevantNamesList, 1, FALSE))) ), Amounts)
The actual result I get using the above code is a 0, which is obviously not correct. I have also tried to use sumproduct, with no success. I am beginning to think that I wont be able to use this without helper columns.
Is there a way to do this without helper columns?
Thanks in advance!
Jacqueline
Give this a try:
=SUMPRODUCT((COUNTIF(<Names To Lookup>,<All Names List>)>0)*(COUNTIF(<Tasks To Lookup>,<All Tasks List>)>0)*<All Amounts List>)
So if you had a data setup like this:
Then the formula would be:
=SUMPRODUCT((COUNTIF($E$2:$E$3,$A$2:$A$5)>0)*(COUNTIF($F$2:$F$4,$B$2:$B$5)>0)*$C$2:$C$5)
EDIT:
Per comment, the lookup criteria could be partial matches. For example, the name in the list is Ms Jennifer Keim and what's being looked up would be Jennifer. In order to accomodate this, you'd need to switch tactics to the DSUM function. This means that you'll need to alter how you setup the criteria.
There are two ways to do this, the first is to create a row for each set of criteria you want, and the second is to have the limited list like you originally have and then setup criteria formulas you then feed into the DSUM. Here's the data setup for the first scenario (note that the lookup headers must exactly match the table headers and that you're putting the wildcards for partial match directly in the criteria):
The DSUM formula in this scenario is:
=DSUM($A$1:$C$5,"Amount",$E$1:$F$7)
For the second scenario, we setup the limited criteria like you originally had it, but now we need helper formulas to feed into the DSUM. Note that the helper formula headers must not be in your original datatable (here i've added "Check" to the end of the header names as an example):
The formulas need to reference the first cell in your datatable and perform the check against your criteria. The DSUM formula will expand that formula's check against every row, so we only need this for the first row to establish the logic that DSUM will use. Here are the two formulas for NameCheck (cell H2 in this example) and TaskCheck (I2). We are using these formulas to allow for partial matches when looking up the criteria against the datatable:
NameCheck: =SUMPRODUCT(--(LEN(SUBSTITUTE(A2,$E$2:$E$3,""))<LEN(A2)))
TaskCheck: =SUMPRODUCT(--(LEN(SUBSTITUTE(B2,$F$2:$F$4,""))<LEN(B2)))
Now the DSUM criteria argument references those formula cells and becomes:
=DSUM($A$1:$C$5,"Amount",$H$1:$I$2)
For further reading and information regarding the DSUM formula, Contextures has a great explanatory article with an example workbook you can download and experiment with: https://contexturesblog.com/archives/2012/11/15/dsum-and-excel-tables-sum-with-multiple-criteria/

Excel Lookup function to isolate duplicate data

I am currently working on a school project alongside a major company to help streamline their shipping process.
We were given two large Excel docs and had to isolate matching shipment numbers from each of the two sheets.
Can I perform a look up function in order to do this? Or is there perhaps a better formula to suit these purposes?
You can use INDEX/MATCH to find every ID where there is at least one match.
INDEX(PullThisData,MATCH(MatchingThisCell,FromThisColumn),0))
To find the number of matches:
If you copy the following formula along each row of data, you can then see how many matches you get on one sheet to the other per shipment ID
IF(COUNTIF(Range,Cell)>1,"",Cell)

how can I find total excluding certain row

Apology if this question has been answered before. In the Summary column I would like to calculate total values for each UserID, excluding Fee which is always 19. As you see there are duplicate UserID's.
I was thinking of using SUMIF'S something like...
=SUMIF(Value, Name,<>"Fee,<>
then I couldn't get it right.
So for example UserID 4836344 total value would be 97.83.
What formula should be used to solve this problem.
Thanks in advance if anyone can help me.
P.S - Let me know if you cannot see the image below.
I would just add another column EffectiveValue that would contain effective value that needs to be added to the total sum. Formula for that column would be something like '=If([Name]="Fee";0;[Value])'.
Then I would sort table by UserId column.
After that I would use Data -> Subtotals feature to produce total sum per user. In wizard you would specify that on every change in UserId calculate sum of EffectiveValue
Sorry if there are syntax mistakes & formatting, but I am writing from mobile phone.
You got your SUMIFS formula almost right. You just need to include the <> within the quotation marks like so:
=SUMIFS($E$2:$E$19,$A$2:$A$19,A2,$D$2:$D$19,"<>Fee")
The above assumes that your sample table starts at A1 with UserID and continues through column E with the values. The above formula would go into cell F2 as the first summary and should be copied down. Keep in mind to adjust the range to include more rows (here only through row 19).
If you have the above sample as a table then you can also use the following formula for F2 and Excel will automatically copy it down:
=SUMIFS([value],[userid],A2,[name],"<>Fee")
To convert your table to an "Excel recognized table" select the entire table and press Ctrl + T as described in more detail on Microsoft's website.
For more information on "Tables in Excel" you might want to read the following articles:
Overview of Excel tables
Use Excel tables to manage information

Lookup Job Code, return column header if cell has text

I'm looking for a little bit of help learning about how to use vlookup and iferror formulas together.
I am working as a licensing specialist within the insurance industry. My job requires that I frequently access more than a dozen spreadsheets that are emailed to us on a weekly basis from our clients. I am working to develop tools that allow us to consolidate that information on-demand to be able to run reports. I'm having no trouble using the VLookup function to pull data from various spreadsheets using an unique identifier. I do need some help, however, with a trickier formula.
I have put together a spreadsheet that allows me to put in the ID of the representative and it returns various bits of information, such as their name, license numbers, job codes, etc. Now I need to come up with a formula that takes the value returned in the job code field and searches another spreadsheet to return what training they are required to complete based on their job code. This spreadsheet is about 2000 rows, and is formatted with the training names spanning across the top row, job codes listed in column "A" and the word "yes" in each column that matches a training that the job code is required to take.
It looks like this: https://i.imgur.com/71COmfF.png
I need the formula in my reports spreadsheet to lookup the job code using VLookup and then return the column header if the cell has text.
The data will be loaded into this spreadsheet: https://i.imgur.com/2CyFURt.png
Here is the Vlookup formula I am using to get the job code:
=VLOOKUP(B3,'.\[Weekly_HR_Report_040615.xlsx]HR'!$A:$Q,10,FALSE)
How can I pair that same kind of formula with something like an IfError formula to return the column header if there is a "Yes" in the cell of the row that matches their job code?
I know that I can work through it as an array using VBA, but I would prefer to just place a formula in each cell so that I can pass this spreadsheet to another college when I move to a different role in the future and they won't struggle too much with adding to it.
Thanks for any help that you might be able to provide! I really appreciate it!
I would use INDEX and MATCH to cross reference and retrieve the titles where applicable:
=IF(INDEX('JobCode_Training.xlsx'!$A$1:$H$6,MATCH($H$5,'JobCode_Training.xlsx'!$A:$A,0),2)="Yes",INDEX('JobCode_Training.xlsx'!$A$1:$H$6,1,2),"")
=IF(INDEX('JobCode_Training.xlsx'!$A$1:$H$6,MATCH($H$5,'JobCode_Training.xlsx'!$A:$A,0),3)="Yes",INDEX('JobCode_Training.xlsx'!$A$1:$H$6,1,3),"")
=IF(INDEX('JobCode_Training.xlsx'!$A$1:$H$6,MATCH($H$5,'JobCode_Training.xlsx'!$A:$A,0),4)="Yes",INDEX('JobCode_Training.xlsx'!$A$1:$H$6,1,4),"")
etc.
I wasn't sure what your reference table is saved as, so you'll need to replace 'JobCode_Training.xlsx'! with whatever the correct path is.
Since you have multiple trainings that can apply to each jobcode, you'll either need to have multiple cells for the results, or you can concatenate them into one.
The following article from excelvlookuphelp.com answers your question I believe...
The Problem
You might be expecting that not all of your search values are going to return something from the search table. Instead of the formula returning #N/A you’d like the result to look different when your vlookup value isn’t found (either blank or an indicator to show that the value hasn’t been found or a zero if you’re wanting to do maths with the results).
The Solution
You can use the iferror function.
It works like this
= iferror (YourVlookupFormula, WhatToSayInsteadOf#N/A)
Here’s an example
=iferror(vlookup(D3,A:C,3,false), “No Value Found”)
Or if you would rather it was just blank then instead of having No Value Found, just have the two sets of inverted commas, like this
=iferror(vlookup(D3,A:C,3,false), “”)
source: excelvlookuphelp

Resources