IF condition

Sahitya

New Member
Joined
May 29, 2018
Messages
27
I have to change the name as per the group in 'Type' column. it is working fine if it is represented as single name, but not with multiple names.

Eg., For Apple, Orange, Watermelon, it should come as Medium, Soft

Formula used in 'Type' Column -

=IF(OR([@Names]="Orange",[@Names]="Watermelon",[@Names]="Banana"),"Soft",IF([@Names]="Apple","Medium",
IF([@Names]="Pineapple","Hard",
"Check Names")))

[TABLE="class: grid, width: 316"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Names[/TD]
[TD]Type[/TD]
[/TR]
[TR]
[TD]Orange[/TD]
[TD]Soft[/TD]
[/TR]
[TR]
[TD]Pineapple[/TD]
[TD]Hard[/TD]
[/TR]
[TR]
[TD]Apple, Orange, Watermelon[/TD]
[TD]Check Names[/TD]
[/TR]
[TR]
[TD]Orange[/TD]
[TD]Soft[/TD]
[/TR]
[TR]
[TD]Banana[/TD]
[TD]Soft[/TD]
[/TR]
[TR]
[TD]Watermelon, Pineapple[/TD]
[TD]Check Names[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
i will be taking dump from sharepoint and which has fruit names which are true or false. With your help i used textjoin to concatenate the 'Names' column.

Problem here is everytime i refresh the dump, data keeps varying and also i will be creating some more validations and from this sheet pivot will be called.:(

is there any other which will help without having a seperate table


[TABLE="class: grid, width: 636"]
<colgroup><col span="5"><col><col></colgroup><tbody>[TR]
[TD]Apple[/TD]
[TD]Orange[/TD]
[TD]Banana[/TD]
[TD]Watermelon[/TD]
[TD]Pineapple[/TD]
[TD]Names[/TD]
[TD]Type[/TD]
[/TR]
[TR]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD]Orange[/TD]
[TD]Soft[/TD]
[/TR]
[TR]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD]Pineapple[/TD]
[TD]Hard[/TD]
[/TR]
[TR]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD]Apple, Orange, Watermelon[/TD]
[TD]Check Names[/TD]
[/TR]
[TR]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD]Orange[/TD]
[TD]Soft[/TD]
[/TR]
[TR]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD]Banana[/TD]
[TD]Soft[/TD]
[/TR]
[TR]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD]Watermelon, Pineapple[/TD]
[TD]Check Names[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Book1
ABCDEFGHIJKL
1AppleOrangeBananaWatermelonPineappleNamesTypeitemtype
2FALSETRUEFALSEFALSEFALSEOrangesoftapplemedium
3FALSEFALSEFALSEFALSETRUEPineapplehardorangesoft
4TRUETRUEFALSETRUEFALSEApple, Orange, Watermelonmedium, soft, softbananasoft
5FALSETRUEFALSEFALSEFALSEOrangesoftwatermelonsoft
6FALSEFALSETRUEFALSEFALSEBananasoftpineapplehard
7FALSEFALSEFALSETRUETRUEWatermelon, Pineapplesoft, hard
Sheet1


In G2 control+shift+enter, not just enter, and copy down:

=TEXTJOIN(", ",TRUE,IF(ISNUMBER(SEARCH(" "&$K$2:$K$6&","," "&$F2&",")),$L$2:$L$6,""))
 
Upvote 0
I will show you a simple example which can tell you whether text in one cell contains something or not:

IF(countif([@Names],"*Apple*")>0,"Medium"

if
[@Names] contains "apple", COUNTIF returns 1, otherwise COUNTIF returns 0.
 
Upvote 0
Thank you Very much, it solves the problem.

Instead of 'medium, soft, soft' can be get as 'medium, soft' without duplicating the type. :confused:

ABCDEFGHIJKL
AppleOrangeBananaWatermelonPineappleNamesTypeitemtype
Orangesoftapplemedium
Pineapplehardorangesoft
Apple, Orange, Watermelonmedium, soft, softbananasoft
Orangesoftwatermelonsoft
Bananasoftpineapplehard
Watermelon, Pineapplesoft, hard

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]3[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]4[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]5[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]6[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]7[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet1



In G2 control+shift+enter, not just enter, and copy down:

=TEXTJOIN(", ",TRUE,IF(ISNUMBER(SEARCH(" "&$K$2:$K$6&","," "&$F2&",")),$L$2:$L$6,""))
 
Upvote 0
I will show you a simple example which can tell you whether text in one cell contains something or not:

IF(countif([@Names],"*Apple*")>0,"Medium"

if
[@Names] contains "apple", COUNTIF returns 1, otherwise COUNTIF returns 0.


Will ii get concatenated names ?
 
Upvote 0
Thank you Very much, it solves the problem.

Instead of 'medium, soft, soft' can be get as 'medium, soft' without duplicating the type. :confused:

In G2 control+shift+enter, not just enter, and copy down:

=TEXTJOIN(", ",TRUE,IF(ISNUMBER(MATCH({"hard","medium","soft"},IF(ISNUMBER(SEARCH(" "&$K$2:$K$6&","," "&$F2&",")),$L$2:$L$6,""),0)),{"hard","medium","soft"},""))
 
Upvote 0
In G2 control+shift+enter, not just enter, and copy down:

=TEXTJOIN(", ",TRUE,IF(ISNUMBER(MATCH({"hard","medium","soft"},IF(ISNUMBER(SEARCH(" "&$K$2:$K$6&","," "&$F2&",")),$L$2:$L$6,""),0)),{"hard","medium","soft"},""))


You are real saviour for me. Thank you very much Mrexcel. :-)
 
Upvote 0

Forum statistics

Threads
1,223,714
Messages
6,174,051
Members
452,542
Latest member
Bricklin

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