Some times we want to calculate how many strings contains certain text. Lets consider this example text:
shahjahankhanalibahadur
shahjahanalibahadurkhan
jahankhanalibahadurshah
shahjahankhanbahadur
jahanalibahadur
I want to find how many of above five contains the text "ali" the formula is simple!! We can use COUNTIF() with a little variation that allows us to "look into each of them for "ali" and then give count of them". Here is the formula:
=COUNTIF(A1:A5,"*"&"ali"&"*")
The result will be 04.
The same thing can be done using SEARCH() with following Array Formula:
=SUM(IFERROR(SEARCH(C1,A1:A5)>=1,0)*1)
This formula seraches for "ALI and gives an array of true & falses and errors, where it find or does not find the match. In order to avoid error message, the IFERROR() function is used to replace them with zeros. When these are multiplied with 1, it assure that all TRUE are replaced by one and then they are summed up by SUM() to give us 04 as a result.
Here is the Sample File
This is a repository to the work I do on Excel, $LaTeX$ and any other interesting thing I came across.
Subscribe to:
Post Comments (Atom)
The Google Sheet Assignment - Splitting and Transposing Cell based on Delimiter - Part 1
I recently had opportunity to workout a formula with google sheets, where i realized how powerful google sheet formulas are. The problem ...
-
PLOTTING THE BASIC CURVE: Since there is no specific equation available to plot the chart therefore I tried to create it in two p...
-
In this post I will be explaining how to run the Simple Linear Regression (Ordinary Least Square) to create the model using Eviews 7.0. Evi...
-
My today’s post is about Survival Analysis with Kaplan-Meier Method. This post uses an example for a popular multivariate analysis tex...
No comments:
Post a Comment