Textjoin, but ignore if qty is zero (or blank)

ellison

Active Member
Joined
Aug 1, 2012
Messages
356
Office Version
  1. 365
Platform
  1. Windows
Hi, we are looking to add a summary of some data by way of a textjoin...
But we'd only like the textjoin to be carried out on info where the corresponding qty is > 0.
Sometimes the corresponding qty can also be blank (please also ignore for the textjoin)
Sorry for the rambling, hopefully this maye help make it more a bit clearer...

textjoin-but-ignore-if-qty-is-zero.xlsm
ABCDEFGHIJK
1RowClass-1Class-1-QtyClass-2Class-2-QtyClass-3Class-3-QtyTextJoin (Straight, but the info isn't the way we would like it)TextJoin (Manual!)Manual Notes (not needed, just to help to explain)
23alpha150gold250alpha ; 150 ; gold ; 250alpha ; 150 ; gold ; 250Alpha and Gold both have accompanying qty's, so include, but skip the blank info in Class-2
34beta100hotel500mike20beta ; 100 ; hotel ; 500 ; mike ; 20beta ; 100 ; hotel ; 500 ; mike ; 20Classes 1,2 & 3 are present, all qty's are > 0, so include all of the info
45charlie0india25novembercharlie ; 0 ; india ; 25 ; novemberindia ; 25Class 1 is present but qty is 0, Class 2 is blank, so only include the info for Class 3
56deltajuliet5delta ; juliet ; 5juliet ; 5Only include the info for Class 3
69foxtrot25kilofoxtrot ; 25 ; kilofoxtrot ; 25Only include the info for Class 1
Sheet1
Cell Formulas
RangeFormula
H2:H6H2=TEXTJOIN(" ; ",TRUE,B2:G2)


Thanks for taking a peek
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Upvote 0
That's shorter than my effort:
LeaveData.xlsx
ABCDEFGH
1RowClass-1Class-1-QtyClass-2Class-2-QtyClass-3Class-3-QtyTextJoin (Manual!)
23alpha150gold250alpha ; 150 ; gold ; 250
34beta100hotel500mike20beta ; 100 ; hotel ; 500 ; mike ; 20
45charlie0india25novemberindia ; 25
56deltajuliet5juliet ; 5
69foxtrot25kilofoxtrot ; 25
Sheet2
Cell Formulas
RangeFormula
H2:H6H2=BYROW(B2:G6,LAMBDA(x,TEXTJOIN(" ; ",,BYCOL(FILTER(WRAPCOLS(x,2),INDEX(WRAPCOLS(x,2),2)>0),LAMBDA(x,TEXTJOIN(" ; ",,x))))))
Dynamic array formulas.
 
Upvote 0
Crumbs, thanks for your help guys, absolutely brilliant - no wonder I couldn't figure that out!!!

I marked up the shorter one for the solution, but both work....

And actually the one from Georgiboy allows you to add in extra columns (i.e. add in Class 4 with qty, Class5 etc)
 
Upvote 0
Can I ask a follow on question from the Georgiboy formula... could something like that also be used to avoid including any duplicated information?

(I think I should probably post that as a separate question - but just in case it's a quick answer, I'll try putting it on here first...)
 
Upvote 0
You mean if the class and QTY is duplicated as below:
Book1
ABCDEFGHIJ
1RowClass-1Class-1-QtyClass-2Class-2-QtyClass-3Class-3-QtyClass-4Class-4-QtyTextJoin (Manual!)
23alpha150gold250alpha ; 150 ; gold ; 250
34beta100hotel500mike20beta ; 100 ; hotel ; 500 ; mike ; 20
45charlie0india25novemberindia ; 25
56deltajuliet5juliet5juliet ; 5
69foxtrot25kilofoxtrot25foxtrot ; 25
Sheet1
Cell Formulas
RangeFormula
J2:J6J2=BYROW(B2:I6,LAMBDA(x,TEXTJOIN(" ; ",,UNIQUE(TOCOL(BYCOL(FILTER(WRAPCOLS(x,2),INDEX(WRAPCOLS(x,2),2)>0),LAMBDA(x,TEXTJOIN(" ; ",,x))))))))
Dynamic array formulas.
 
Upvote 0
Solution
Oh my gosh that is astonishing! Wow, yes - that's exactly what I meant.....

(Sorry Peter, I changed the solution to the one above as this version of the solution can also cope with extra columns being added - and can also offer the dedupe. Totally appreciate I hadn't mentioned either of those in my first post though, apologies)
 
Upvote 0
Sorry Peter, I changed the solution to the one above as this version of the solution can also cope with extra columns being added - and can also offer the dedupe.
No need to apologise - you should choose whichever one suits you best.

Never-the-less I'm not sure what makes you think that my style of formula cannot cope with more columns (or dupes)

23 10 09.xlsm
BCDEFGHIJ
1Class-1Class-1-QtyClass-2Class-2-QtyClass-3Class-3-QtyClass-4Class-4-QtyTextJoin
2alpha150gold250alpha ; 150 ; gold ; 250
3beta100hotel500mike20beta ; 100 ; hotel ; 500 ; mike ; 20
4charlie0india25novemberindia ; 25
5deltajuliet5juliet5juliet ; 5
6foxtrot25kilofoxtrot25foxtrot ; 25
TJ (2)
Cell Formulas
RangeFormula
J2:J6J2=TEXTJOIN(" ; ",1,UNIQUE(IF(ISNUMBER(C2:I2),IF(C2:I2>0,B2:H2&" ; "&C2:I2,""),""),1))
 
Upvote 0

Forum statistics

Threads
1,223,770
Messages
6,174,433
Members
452,563
Latest member
mvdk

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