Home / Computer Science / Microsoft PowerBI / 3 Best Steps to Get Substring after nth Occurance of Symbol in Excel

3 Best Steps to Get Substring after nth Occurance of Symbol in Excel

In the realm of Data Analysis and Digital Marketing, we frequently encounter scenarios where we must extract numerical values that follow specific symbols or special characters like “$” or “=” within a provided string. This need becomes more intricate when the said symbols appear multiple times within the string. In such cases, our objective is to pinpoint the second occurrence of the designated symbol and subsequently capture the corresponding substring or numeric value, thereby populating a distinct column with this information. In this post we discuss about 3 Steps to Get Substring after nth Occurance in Microsoft Excel.

See the below image, in this Image Column A has Url’s and Column B is empty. No we need data in B. The expected data in B column is last digits after “=” symbol.

3 Best Steps to Get Substring after nth Occurance of Symbol in Excel 1
3 Best Steps to Get Substring after nth Occurance of Symbol in Excel 2

To get the data in column B, use a formula in column B2.

=RIGHT(A2, LEN(A2) - SEARCH("^^", SUBSTITUTE(A2, "=", "^^", 2)))

Now we get the value as expected in column B and drag upto end.

3 Steps to Get Substring after nth Occurance
3 Best Steps to Get Substring after nth Occurance of Symbol in Excel 3

explanation of the formula:

To extract the number after the second occurrence of the equal symbol (=) or any special symbol in a string using the RIGHT, SEARCH, and LEN functions in Excel, you can use a combination of these functions. Let’s assume your string is in cell A1, and you want to extract the number after the second equal symbol in another cell (let’s say B1). Here’s how you can do it:

To extract the number after the second occurrence of the equal symbol (=) in a string using the RIGHT, SEARCH, and LEN functions in Excel, you can use a combination of these functions. Let’s assume your string is in cell A1, and you want to extract the number after the second equal symbol in another cell (let’s say B1). Here’s how you can do it:

Explanation of the formula:

SUBSTITUTE(A1, “=”, “^^”, 2): This substitutes the second occurrence of “=” with “^^” in the string. This avoids confusion since “^” is a special character used to escape other characters.

SEARCH(“^^”, SUBSTITUTE(A1, “=”, “^^”, 2)): This finds the position of the second occurrence of “^^” in the modified string.

LEN(A1) – SEARCH(“^^”, SUBSTITUTE(A1, “=”, “^^”, 2)): This calculates the length of the portion of the string after the second “=”.

RIGHT(A1, LEN(A1) – SEARCH(“^^”, SUBSTITUTE(A1, “=”, “^^”, 2))): This extracts the portion of the string after the second “=”.

Other articles on Data Analytics or Power Bi is here.

Microsoft Excel functions here.

About Santosh Kumar Gadagamma

I'm Santosh Gadagamma, an Experienced Software Engineer passionate about sharing knowledge in technologies like Java, C/C++, DBMS/RDBMS, Bootstrap, Big Data, Javascript, Android, Spring, Hibernate, Struts, and all levels of software design, development, deployment, and maintenance. I believe computers are essential for the world's functioning, and I'm committed to helping others learn the skills they need to succeed in tech. My website is a valuable learning tool to help you reach greater heights in your education and career, and I believe that education has no end points.

Check Also

Exploring Top 5 Google AdSense Alternatives for Monetizing Your WordPress Website

Discover the top 5 Google Adsense alternatives , tailored to optimize revenue and provide flexibility for online publishers. Explore diverse ad networks and find the perfect match for your website