special usage of logical-test for IF function

luckypurchase

New Member
Joined
Aug 2, 2011
Messages
16
Dear reader,

I like to use the following function:
=IF(A1="tax";"non-purchase";" purchase")

Right now, Logical-test = equal to "tax"

Though, I like the logical-test to detect any kind of combination with the word "tax". example transportationtax must give me = true and so "non-purchase" will appear.

Thank you in advance

Bye
<TABLE style="WIDTH: 48pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=64><COLGROUP><COL style="WIDTH: 48pt" width=64><TBODY><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: transparent; WIDTH: 48pt; HEIGHT: 15pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" height=20 width=64></TD></TR></TBODY></TABLE>
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Dear reader,

I like to use the following function:
=IF(A1="tax";"non-purchase";" purchase")

Right now, Logical-test = equal to "tax"

Though, I like the logical-test to detect any kind of combination with the word "tax". example transportationtax must give me = true and so "non-purchase" will appear.

Thank you in advance

Bye
<TABLE style="WIDTH: 48pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=64><COLGROUP><COL style="WIDTH: 48pt" width=64><TBODY><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: transparent; WIDTH: 48pt; HEIGHT: 15pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" height=20 width=64></TD></TR></TBODY></TABLE>

Are there a lot of combinations with the word "tax"? If it's only a few, I would just do an OR statement for your logical test. Also, you should be using commas, not semicolons, to separate your arguments like I have below.

Code:
=IF(OR(A1="tax",A1="transportationtax",A1="salestax"),"Non-Purchase","Purchase")
 
Upvote 0
=IF(ISNUMBER(FIND("tax", A1)), "non-purchase", "purchase")

Just curious, how would ISNUMBER work there? I haven't used the ISNUMBER/ISERROR/ISBLANK functions much at all, but if it's in quotes ("tax") doesn't that indicate text?
 
Upvote 0
Are there a lot of combinations with the word "tax"? If it's only a few, I would just do an OR statement for your logical test. Also, you should be using commas, not semicolons, to separate your arguments like I have below.

Code:
=IF(OR(A1="tax",A1="transportationtax",A1="salestax"),"Non-Purchase","Purchase")


Yes there are about 22000 rows in columA with various words with tax (salestax, valueaddedtax, transportationtax etc). Moreover, words like fines etc. need to be find by the function as well.

Thank you in advance!
 
Upvote 0
Just curious, how would ISNUMBER work there? I haven't used the ISNUMBER/ISERROR/ISBLANK functions much at all, but if it's in quotes ("tax") doesn't that indicate text?

FIND finds the position of a substring within another string.
If A1 contains "free tax", FIND("tax",A1) returns 6
If A1 contains "cat", FIND("tax", A1) returns a #VALUE error

ISNUMBER(FIND("tax",A1)) returns TRUE if A1 has "tax" as a substring.
 
Upvote 0
Just a couple of comments:

1. I would suggest changing FIND to SEARCH in the formula suggested by Mike. So ..
=IF(ISNUMBER(SEARCH("tax", A1)), "non-purchase", "purchase")

We haven't seen your data but if it is possible that A1 contained "Sales Tax" then FIND("tax",A1) would not locate "Tax" but SEARCH("tax",A1) would.

Another option would be

=IF(COUNTIF(A1,"*tax*"),"non-purchase","purchase")

2. It is quite likely not possible with your data but these FIND/SEARCH/COUNTIF functions would also identity as "tax" even if A1 contained "I went by taxi".
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top