[Solved] If "specific text" exists, then 1, else 0

Discuss the spreadsheet application
Locked
alienrobotghost
Posts: 16
Joined: Thu Jun 25, 2020 10:01 am

[Solved] If "specific text" exists, then 1, else 0

Post by alienrobotghost »

I need a formula that will check if the text in a cell contains the text "bio", anywhere in the text, and return a 1 if it does, and a 0 if it doesn't


is this something that is possible?
Last edited by alienrobotghost on Thu Jan 09, 2025 6:26 am, edited 1 time in total.
openoffice 4.1.1 on windows 7
User avatar
robleyd
Moderator
Posts: 5505
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: if "specific text" exists, then 1, else 0

Post by robleyd »

Yes. One way would be to use the FIND() function wrapped in an IF().
Slackware 15 (current) 64 bit
Apache OpenOffice 4.1.16
LibreOffice 26.2.3.2; SlackBuild for 26.2.3 by Eric Hameleers
---------------
I hate this damn computer, I wish that I could sell it.
It won't do what I want it to, Only what I tell it.
alienrobotghost
Posts: 16
Joined: Thu Jun 25, 2020 10:01 am

Re: if "specific text" exists, then 1, else 0

Post by alienrobotghost »

robleyd wrote: Wed Jan 08, 2025 8:45 am Yes. One way would be to use the FIND() function wrapped in an IF().
I tried that... and failed miserably... lol
openoffice 4.1.1 on windows 7
User avatar
robleyd
Moderator
Posts: 5505
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: If "specific text" exists, then 1, else 0

Post by robleyd »

What exactly did you try? And what was the result?
 Edit: You'll need an ISERR() in there as well. 
Slackware 15 (current) 64 bit
Apache OpenOffice 4.1.16
LibreOffice 26.2.3.2; SlackBuild for 26.2.3 by Eric Hameleers
---------------
I hate this damn computer, I wish that I could sell it.
It won't do what I want it to, Only what I tell it.
User avatar
Lupp
Volunteer
Posts: 3756
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: If "specific text" exists, then 1, else 0

Post by Lupp »

Assume column $A contains the strings. You will get the numeric results you mentioned to indicate the presence of the substring "bio" by

Code: Select all

= 0 + ISNUMBER(FIND("bio"; $A1))
The

Code: Select all

0+
makes Calc format the result cell to "Number / General" automatically.
If you prefer to get the results formatted automatically as Boolean (logical) use

Code: Select all

= ISNUMBER(FIND("bio"; $A1))
If you want a case insensitive formula use

Code: Select all

= 0 + ISNUMBER(FIND(UPPER(substring); UPPER($A1)))
and respectively.
Last edited by Lupp on Wed Jan 08, 2025 4:17 pm, edited 1 time in total.
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
MrProgrammer
Moderator
Posts: 5430
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: If "specific text" exists, then 1, else 0

Post by MrProgrammer »

alienrobotghost wrote: Wed Jan 08, 2025 8:30 am I need a formula that will check if the text in a cell contains the text "bio", anywhere in the text, and return a 1 if it does, and a 0 if it doesn't
=N(SUBSTITUTE(cell;"bio";"")<>cell)

If this solved your problem please go to your first post use the Edit ✏️ button and add [Solved] to the start of the Subject field. Select the green checkmark icon at the same time.

[Tutorial] Ten concepts that every Calc user should know
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
alienrobotghost
Posts: 16
Joined: Thu Jun 25, 2020 10:01 am

Re: If "specific text" exists, then 1, else 0

Post by alienrobotghost »

You guys are the best!!!
openoffice 4.1.1 on windows 7
Locked