COUNTIF Partial Match - excel

I am working on a password audit, and one of the tasks I'm trying to solve is counting the number of instances a username is present in the password. For instance, the username might be 'mikeb' and their password is 'mikeb123'.
Searching for a username in a password is simple enough: COUNTIF(A:A, "mikeb")
The problem I'm running into is how to I check A1 against B1, A2 against B2, for the entire column, and add up the number of times that B contained A.
Currently I'm using a workaround where I make the comparison then count the number of true values in a separate column. I'd like to get away from another column if possible.
EDIT: Per request, dummy data:
Username Password Password Contains Username?
Bob BobHasASneakyPa$$word TRUE
Carol No1LikesUCarol TRUE
Admin <>##Admin##<> TRUE
Brian ;Ui6$m8/4??k3&)r7 FALSE
This is what my data looks like right now. I am using COUNTIF(A2, "*" & B2 & "*")>0 for the third column, then doing COUNTIF(C:C, "TRUE") to count up the # of times this happens. Ideally I'd combine these into one equation.

Try using
=SUMPRODUCT(--ISNUMBER(SEARCH(A2:A5,B2:B5)))
I've tested this on your dummy data and searched for the username in the password. It returns an answer of 3 which would be the same as summing your third column.
You could also make this case sensitive if needs be by changing SEARCH to FIND

Related

Creating a binary flag to return whether someone has used a product in the last n days

I have three variables: the person using the item, the date the item was used, and the brand. I'd like to create a flag that indicates whether a specific brand (in this case, BrandA) was used in the last n days by a given person.
The Y-AA columns are an example of the data that I'm working with, and the AB column is the desired result.
Example
I know at the end I'll probably have =if( , True, False), but I'm not sure what would make up the argument.
Any help would be appreciated, thank you!
I think you need to consider how you're setting up your data. Below is an example of how you can create your IF conditions to make it work -- using data that is unclear in your post.
Set up your data like so, with cell Z1 using the name AnchorDate.
Then the formula entered in cell AB4 and copied down and across will be
=IF(AND($Y4=AB$1,$AA4=AB$2,DAYS(AnchorDate,$Z4)<=10),"Yes","No")

How to fix a Index+Match based on input value thats also dynamic

I have a great challenge I hope you can help me with.
What I want to achieve:
In the sheetname “Overal campaign information” I have an identical setup to the other sheetnames (for example Week 1 – Email, Week 1 – CPC and so on).
I want to user to first select their week and year and based (under E1) on these to selections, you can select a type that matches that week and year input.
What have I tried?
I have written an INDEX+MATCH that works well, but that is based on a hard coded sheet name and is not dynamic.
I have also tried the INDIRECT function to find information regardless of worksheet name, but failed hard
I have tried to CONCATENATE year+week to get a key to match against point 1, but also not succeeded
Wanted result
Based on the time frame selection (week and year) the type will show available types that matches that input.
Then it will fill in the information in C1:C13 and B17:V:300
Not really clear what you means by "fill in the information in C1:C13". But formula in 'Overal campaign information'!B17 could be
=OFFSET(INDIRECT("'Week "&$F$2&" - " & $F$4&"'!$B$17"),ROW(B17)-17,COLUMN(B17)-2)
This then can be filled into 'Overal campaign information'!B17:V300.

Convert Formula Numerical Value to Matched Strings

I have the following formula that checks a username against a range of usernames, determines whether that username belongs to one of three domains, and whether that username is marked as an Administrator:
=SUMPRODUCT(COUNTIFS(Tbl_Data[Username],Rng_ITEmp,Tbl_Data[Domain],{"D1","D2","D3"},Tbl_Data[Member of Groups], "*Administrators*"))
This formula works wonderfully! I'd like to dig a little deeper though and actually print out the usernames that satisfied this query. Is there a way to go from this equation to the values that came back as TRUE?

COUNTIF and IF to return value

Example Data Picture:
Basically associates use two different systems to log calls and there is a scenario where the same call is logged on two different systems. It gives a unique ID for each call, so perceived two be two calls instead of one. I need to be able to match these up and present as one call.
Data being used and to look up.
Call ID
Unique Client ID
Date
The System is the field I need to return the value for - above is a dummy result I would ideally like.
As you can see from the picture for Client 'ABC' there have been two entries on same day with different Call IDs, so I would want to show different systems have been used, for the other entries they are 'purely' unique so show 1 system.
I have tried COUNTIFS with date logic but can't get anything to work or come close.
This is only one part to the formula as I would then need to go onto checking time of call validations as well but that's for another time.
What I really need - which would work better - would be if Client ID is duplicated on Same Day then show True - If not show false?
if Client ID is duplicated on Same Day then show True - If not show false
Please try in D2 and copied down to suit:
=COUNTIFS(C:C,C2,B:B,B2)>1
I can't see your picture, but from your description;
If you have Call ID Unique in Column A and Call ID Date in Column B, assuming your data is contained in rows 2 to 50, place this function in cell C2 and drag down, if the function finds any duplicates, the count will be increased from 1 to the number of duplicates found in the list:
=IF(AVERAGEIF($B$2:$B$50,B2,$A$2:$A$50)/COUNTIF($B$2:$B$50,B2)<>AVERAGEIF($B$2:$B$50,B2,$A$2:$A$50),COUNTIF($B$2:B2,B2),1)
Then you can just filter out anything that's not a 1
Edit If you want to change the outputs to True or False, just do the following instead:
=IF(AVERAGEIF($B$2:$B$50,B2,$A$2:$A$50)/COUNTIF($B$2:$B$50,B2)<>AVERAGEIF($B$2:$B$50,B2,$A$2:$A$50),TRUE,FALSE)
However, this will flag all occurrences of the calls as True, if you want just the duplicates to be flagged, it would be:
=IF(AVERAGEIF($B$2:$B$50,B2,$A$2:$A$50)/COUNTIF($B$2:$B$50,B2)<>AVERAGEIF($B$2:$B$50,B2,$A$2:$A$50),IF(COUNTIFS($B$2:B2,B2,$A$2:A2,A2)>1,TRUE,FALSE),FALSE)

Excel: How to parse/cast text as a formula?

Is it possible to parse/cast text (like "=A1+A2") as a formula in MS Excel? I want to build a formula from pieces of text - some of which will only be typed in later by a user.
If the INDIRECT() function did not only work for referencing cells, then I could have typed this =INDIRECT("=A1+A2").
I know you can a work around this problem by simply adding a lot more hidden columns to do sub calculations. But for the sake scalability and efficiency, I would rather do something like the above.
I found a similar questions here and here, yet they don't solve my problem.
The Real-world problem:
Read on for a better understanding as to why you would want to do the above
Scenario
Each item in the list consists of a string, which contains anywhere from 1 to 5 account names each. Each account name is followed by an account number in brackets. The length of the number determines the type of account. Part of the account number is a date, of which the date format depends on the type of account. Further more, each account type may have more that 1 account-number length associated with it, although each number-length[*] is only associated with 1 account type.
Objectives
Extract account-names and their respective account-numbers and account-types from a list.
Make an assumption as to the account-type from the account-number
Validate this assumption by inspecting the build of the number and elements in the name
Check the validity of the account-numbers depending on their type.
The tricky part (this is where my problem lies)
The account-types and their respective account-number-lengths are not known before hand, and are typed into a table by the user of the sheet, specifying a type of account and the number-lengths associated with this account-type. The user should type this into a list - not go and tinker around with delicate formulas
Done so far
Column A: Contains the raw data (each cell has up to 5 names and numbers)
Columns B..F: Each column extracts 1 name, remains empty if all are already extracted
Columns G..K: Each column extracts 1 number corresponding to its name in columns B..F, remains empty if all are already extracted
Columns L..P: Each column calculates the length of the corresponding number in columns
G..K
Now the user would type the following details into a table which assigns certain number-lengths an account type:
TYPE2, BUSINESS, (OR(length=13,length=6))
where length will later be replaced with the cell address which contains the calculated account number-length.
What I want to do now
Columns Q..U:
Should all indicate the account-type of the corresponding account-number in columns G..K. The idea is to build a nested if-elseIf-elseIf formula using the criteria typed in by the user as specified above. Example of one of the elseIF statements:
SUBSTITUTE(CONCATENATE("=IF(",criteria,",",type,",",errCode)),"length","O10"))
All of these elseIf statements will then be concatenated together to form a master formula which will then need to be parsed/cast as a formula to calculate the account-type
This proposal uses only 5 columns (1 for each account-number, containing the master formula) and a table specifying account-types and criteria, also keeping the user away from formulas. Editing 1 line of code (the criteria) will update all formulas. Efficient & Scalable.
Since the user should never tinker around with the formulas under the hood, a simple 1 column if-elseIf-elseIf is out of the question. The alternative to the above would be to make a separate column to test for each account-type for each account-number. Separating/Abstracting out each test to its own column results in much better readability, easier editing & much less debugging - Unless you like multi-screen-wide-formulas. Example: 5 account-numbers * 10 possible account types = 50 extra columns.
Each edit to any criteria needs to copied to 4 other non-adjacent columns and drag-filled down 10,000 rows (columns can not be adjacent since it is effectively a 5x5 array of columns). Not Efficient nor scalable. Unless I'm missing some elegant way of updating non-adjacent formulas in a single click
The rest of the validations error indications are trivial.
Sample data
Tshepo Trust (6901/2005) Marlene Mead (8602250646085)
Great Force Inv 67 Pty Ltd (200602258007)
Jane (870811) Livingstone (6901/2005) Janette Appel (8503250647056) James (900111)
I know all this would probably be much easier to achieve with clever usage of VBA, eliminating all the need to simulate abstraction, encapsulation, multi-dimensional arrays and functional programming on a spreadsheet. But until I can program in VBA, worksheet formulas will be my refuge.
[*]: account number-length could also be described as the amount of digits in the number or as indicated by this formula: LEN(accNumber)
In VBA you have access to Cell.Formula.
I usually used Range to peek a cell by address.
I'm not sure if this would answer your question(it's a very detailed question!), but if your user was entering the account numbers in a table (I'm calling it 'RefTable') , that was:
Length of account number | business type
----------------------------------------
6 | Accountant
8 | Advisor
Then you could just use a vlookup on the length of the account number, given you've already separated them out.
=vlookup(len(accNumber), Reftable, 2, false)
Make sure that you either use a dynamic range name, or specify plenty of space below in RefTable, so that when your users add types, they don't get lost.
Also, if you have two different accounts with the same length, this could get you into trouble.

Resources