Concatenate and IF Formula

Ryske

New Member
Joined
Mar 22, 2017
Messages
6
Hi Everyone!
Below is the Row 1 is a commodity and in row 2 is the number of pallets. Anything that more than "0" the commodity will appear in "Output" but with "/" as a separator in each commodity, which I do not know what formula would it be? Thanks in advance.

=CONCATENATE(IF(A2>0,"BREAD",""),IF(B2>0,"FROZEN",""),IF(C2>0,"WATER",""),IF(D2>0,"FFV",""))

BREADFROZENWATERFFVTOTALOUTPUT
222511BREAD/FROZEN/WATER/FFV

<tbody>
</tbody>

 

S.H.A.D.O.

Well-known Member
Joined
Sep 6, 2005
Messages
1,915
Welcome to the board Ryske,

How about something like this:

Code:
=CONCATENATE(IF(A2>0,A2&" BREAD/",""),IF(B2>0,B2&" FROZEN/",""),IF(C2>0,C2&" WATER/",""),IF(D2>0,D2&" FFV",""))
I hope this helps!
 

Eric W

MrExcel MVP
Joined
Aug 18, 2015
Messages
8,994
If you have one of the newer versions of Excel (365 or some 2016), you can use the TEXTJOIN:


=TEXTJOIN("/",TRUE,IF(A2:D2>0,A$1:D$1,""))


or


=TEXTJOIN("/",TRUE,IF(A2:D2>0,A2:D2&" "&A$1:D$1,""))


both confirmed with Control+Shift+Enter.




If not, you can use S.H.A.D.O.'s formula. However, do you care if the result has a trailing "/" ? That will happen if FFV = 0. It would take a longer formula to get around that, something like:

=IF(SUM(A2:D2),SUBSTITUTE(IF(A2>0,"BREAD/","")&IF(B2>0,"FROZEN/","")&IF(C2>0,"WATER/","")&IF(D2>0,"FFV/",""),"/","",COUNTIF(A2:D2,">0")),"")
 

Ryske

New Member
Joined
Mar 22, 2017
Messages
6
Hello Eric W, thanks, this helps as well. I have used the first "textjoin" formula and it works perfectly.
To answer your question, FFV should not have "/". I have removed the "/" from FFV, the desired output is achieved. Thanks once again!
 

Nishant94

Well-known Member
Joined
May 8, 2015
Messages
507
Although you have got your answer, here is my way of doing it. Just few modification to the above answers.

<b>Excel 2016</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB"><colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="font-weight: bold;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #FFFFFF;background-color: #00B0F0;;">BREAD</td><td style="font-weight: bold;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #FFFFFF;background-color: #00B0F0;;">FROZEN</td><td style="font-weight: bold;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #FFFFFF;background-color: #00B0F0;;">WATER</td><td style="font-weight: bold;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #FFFFFF;background-color: #00B0F0;;">FFV</td><td style="font-weight: bold;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #FFFFFF;background-color: #00B0F0;;">TOTAL</td><td style="font-weight: bold;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #FFFFFF;background-color: #00B0F0;;">OUTPUT</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">2</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">2</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">2</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">5</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">11</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">BREAD/FROZEN/WATER/FFV/</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">1</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">0</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">2</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">6</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">9</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">BREAD/WATER/FFV/</td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">4</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">2</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">5</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">11</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">BREAD/FROZEN/FFV/</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #BBB;border-top:none;text-align: center;background-color: #DAE7F5;color: #161120">Sheet3</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #BBB"><thead><tr style=" background-color: #DAE7F5;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">F2</th><td style="text-align:left">=CONCATENATE(<font color="#0000FF">IF(<font color="#FF0000">A2,$A$1&"/",""</font>),IF(<font color="#FF0000">B2,$B$1&"/",""</font>),IF(<font color="#FF0000">C2,$C$1&"/",""</font>),IF(<font color="#FF0000">D2,$D$1&"/",""</font>)</font>)</td></tr></tbody></table></td></tr></table><br />


OR

<b>Unknown</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB"><colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="font-weight: bold;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #FFFFFF;background-color: #00B0F0;;">BREAD</td><td style="font-weight: bold;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #FFFFFF;background-color: #00B0F0;;">FROZEN</td><td style="font-weight: bold;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #FFFFFF;background-color: #00B0F0;;">WATER</td><td style="font-weight: bold;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #FFFFFF;background-color: #00B0F0;;">FFV</td><td style="font-weight: bold;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #FFFFFF;background-color: #00B0F0;;">TOTAL</td><td style="font-weight: bold;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #FFFFFF;background-color: #00B0F0;;">OUTPUT</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">2</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">2</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">2</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">5</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">11</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">BREAD/FROZEN/WATER/FFV</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">1</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">0</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">2</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">6</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">9</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">BREAD/WATER/FFV</td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">4</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">2</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">5</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">11</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">BREAD/FROZEN/FFV</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #BBB;border-top:none;text-align: center;background-color: #DAE7F5;color: #161120">Sheet3</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Array Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #BBB"><thead><tr style=" background-color: #DAE7F5;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">F2</th><td style="text-align:left">{=TEXTJOIN(<font color="#0000FF">"/",,IF(<font color="#FF0000">A2:D2,$A$1:$D$1,""</font>)</font>)}</td></tr></tbody></table><b>Enter the formula with "Ctrl+Shift+Enter". Only Pressing "Enter" will result in formula giving error or incorrect result. </b> If entered correctly, Excel will surround with curly braces {}.
<b>Note: Do not try and enter the {} manually yourself</b></td></tr></table><br />
 

Ryske

New Member
Joined
Mar 22, 2017
Messages
6
Thank you Nishant, another formula that I can use in future.
 
Joined
Mar 23, 2017
Messages
6
You can use both formulas,,

1. =CONCATENATE(IF(A2>0,A2&" BREAD/",""),IF(B2>0,B2&" FROZEN/",""),IF(C2>0,C2&" WATER/",""),IF(D2>0,D2&" FFV",""))

2. =
IF(SUM(A2:D2),SUBSTITUTE(IF(A2>0,"$A$1&"/","")&IF(B2>0,"$B$1&"/","")&IF(C2>0,"$C$1&"/","")&IF(D2>0,"$D$1&"/",""),"/","",COUNTIF(A2:D2,">0")),"")


Thanks,
Dinesh Babu K
****** id="cke_pastebin" style="position: absolute; top: 41px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
=CONCATENATE(IF(A2,$A$1&"/",""),IF(B2,$B$1&"/",""),IF(C2,$C$1&"/",""),IF(D2,$D$1&"/",""))

<tbody>
</tbody>
=CONCATENATE(IF(A2,$A$1&"/",""),IF(B2,$B$1&"/",""),IF(C2,$C$1&"/",""),IF(D2,$D$1&"/",""))

<tbody>
</tbody>
=CONCATENATE(IF(A2,$A$1&"/",""),IF(B2,$B$1&"/",""),IF(C2,$C$1&"/",""),IF(D2,$D$1&"/",""))

<tbody>
</tbody>
=CONCATENATE(IF(A2,$A$1&"/",""),IF(B2,$B$1&"/",""),IF(C2,$C$1&"/",""),IF(D2,$D$1&"/",""))

<tbody>
</tbody>
</body>
 
Joined
Mar 23, 2017
Messages
6
Hi,

You can ues both the formulas,

1.
=CONCATENATE(IF(A2>0,A2&" BREAD/",""),IF(B2>0,B2&" FROZEN/",""),IF(C2>0,C2&" WATER/",""),IF(D2>0,D2&" FFV",""))

2.
=IF(SUM(A2:D2),SUBSTITUTE(IF(A2>0,$A$1&"/","")&IF(B2>0,$B$1&"/","")&IF(C2>0,$C$1&"/","")&IF(D2>0,$D$1&"/",""),"/","",COUNTIF(A2:D2,">0")),"")


Thanks,
Dinesh Babu.
 

Forum statistics

Threads
1,082,258
Messages
5,364,090
Members
400,779
Latest member
lumers

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top