How to find out if a text contains question? [Excel formulas]

Share

Facebook
Twitter
LinkedIn

Few days back, I ran my first ever webinar, on a topic called, “How to be a BETTER Analyst?” (here is the replay link, in case you missed it).  It was a huge success. More than 1,100 people attended the live webinar and hundreds more watched the replay. As part of the webinar, we had interactive Q&A. Viewers posted their questions and I replied to as many of them as I can.

After the webinar, I wanted to make sure I covered all the questions. So I downloaded the chat history. There were more than 700 messages in it. And I am not in the mood to read line by line to find-out the questions. A good portion of chat messages were not questions but stuff like ‘hello everyone, I am from Idaho’, ‘Wow, Chandoo has beard!”, “Enjoying a beer in Belgium while watching webinar” etc. So I wanted a quick way to flag the messages as question or not.

finding-if-cell-has-question-in-it

I did what any sensible Excel analyst would do.

I made myself a hot cup of coffee, started playing games on my iPhone while sipping it.

Of course after a cup of coffee and a bout of Candy Crush, I wrote simple Excel formula to find-out if the text in a cell is question or not. Let me share the formula & logic with you.

Let’s take a look at the data

This is how the downloaded chat history looked like when imported to Excel. The column on right is where we need to write formula to find out if the comment is a question or not.

For the sake of simplicity, assume this data is in column B, starting with cell B5.

The logic for identifying questions

In real life, finding if the other person is asking a question or just saying something can be tricky. For example, last evening my wife said, “Shall we go shopping?” and I assumed it was a question and said “no”. Apparently, it wasn’t a question. You can guess the rest.

question-wordsUnlike real life, in Excel, we can come up with good enough approximation to nail down questions.

For example, if a cell contains any of the below words, we can say it is a question.

What, why, how, who, when, where, is it, can I, can you, which, is this, are you, can we, are we, am I

This is a pretty good way to separate questions from non-questions.

Let’s assume all the question words are maintained in a named range called q.words

Writing the formula

So here is the formula to check if a cell contains question or not.

=SUMPRODUCT(COUNTIFS(B5,"*"&q.words&"*"))>0

How does this formula work?

Remember, B5 is the cell in question (no pun).

We need to see anywhere in B5, one of the question words occur.

This is where COUNTIFS formula helps. It can count how many times a value has occurred in a range.

In our case, if B5 contains any of the question words. Note that B5 can contain other text too (apart from question words).

The formula COUNTIFS(B5,"*"&q.words&"*") will return an array of size 15 (as q.words contains 15 question words).

Let’s assume B5 has the text – “Why didn’t you take your wife to shopping?”

So, our COUNTIFS(B5...) will return the array {0;1;0;0;0;0;0;0;0;0;0;0;0;0;0}

The second item is 1 because second question word is Why.

If B5 has this text – “How I wish I took my wife to shopping. Can I take her now?”

COUNTIFS(..) will return this array {0;0;1;0;0;0;0;1;0;0;0;0;0;0;0} because it found the question words How and Can I.

But we don’t want the array…

You are right. We don’t need the array of 15 elements. We just want to know if any of the questions are present in the B5 cell.

So, we pass this array to SUMPRODUCT, which sums up all the numbers and tells us single value.

We then check if this value is >0 or not.

So there you have it. A formula to find out if a cell has question or not.

A question for you…

Do you conduct text analysis using Excel? What techniques do you use? Please share your approach & formulas in the comments.

Bonus material for text analysis using Excel

If you deal with lots of text data, you will find below resources very useful.

Now if you excuse me, I need to take my wife for shopping. 🙂

Facebook
Twitter
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Overall I learned a lot and I thought you did a great job of explaining how to do things. This will definitely elevate my reporting in the future.
Rebekah S
Reporting Analyst
Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

5 Responses to “Show more of your workbook on screens [quick tip]”

  1. Bda75 says:

    In 2013 you can also add to the QAT the hidden command "Toggle Full Screen View".

  2. Chris Newman says:

    Instead of using the shortcut CTRL+F1, I prefer just to double-click one of the tab names (ie double-click the "Home" text on the Home tab) to enable the Ribbon Outline view. To return to the normal Ribbon state, just double-click your mouse again!

  3. liu says:

    press Ctrl+Shift+F1, you will get a full screen

  4. efand says:

    Instead of Ctrl + F1, I use Ctrl + Shift + F1 (Excel 2016)

  5. Jay says:

    Alt W E sequence for full screen
    ESC to get back

Leave a Reply