Concatenate in Different Scenarios

shah0101

Board Regular
Joined
Jul 4, 2019
Messages
175
Hi Experts,

Following is the data and I want to concatenate the numbers with unit. The data is extracted from (=SUMIFS()).


[TABLE="width: 427"]
<colgroup><col span="2"><col><col></colgroup><tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD][/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Quantity[/TD]
[TD] Formula Enetered[/TD]
[TD]Unit[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1219[/TD]
[TD]=SUMIFS(F42:F71,G42:G71,"PCS")[/TD]
[TD] PCS [/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]1377[/TD]
[TD]=SUMIFS(F42:F71,G42:G71,"KGS")[/TD]
[TD] KGS [/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]1750[/TD]
[TD]=SUMIFS(F42:F71,G42:G71,"SET")[/TD]
[TD] SET [/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]938[/TD]
[TD]=SUMIFS(F42:F71,G42:G71,"YDS")[/TD]
[TD] YDS [/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]1100[/TD]
[TD]=SUMIFS(F42:F71,G42:G71,"MTR")[/TD]
[TD] MTR [/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]2390[/TD]
[TD]=SUMIFS(F42:F71,G42:G71,"PAR")[/TD]
[TD] PAR [/TD]
[/TR]
</tbody>[/TABLE]



Sometimes there is only one unit i.e. "PCS" or two units i.e. YDS and PAR or sometimes all seven units.

What I am trying to achieve is get the quantity and unit if it is present otherwise return void.

I mean if there is only 938 YDS then a cell must return: "938 YDS".
I mean if there are 1750 SET and 1100 MTR then a cell must return: "1,750 SET, 1,100 MTR".
I mean if there are 1750 SET and 1100 MTR and 1377 KGS then a cell must return: "1,750 SET, 1,100 MTR", 1,377 KGS".


Please guide / advise.

Thanks in advance.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi, welcome to the forum!

If I understand correctly, you can change your SUMIFS() formula, for example - to the below:

Code:
=SUMIFS(F42:F71,G42:G71,"PCS") & " PCS"
 
Upvote 0
Thanks FormR,

If I understand correctly, this would work with only one UNIT i.e. PCS, but I have another UNITS and their relevant quantities as well.

Please advise.

Thanks,
 
Upvote 0
Hi, sorry but I don't understand then.

Your SUMIFS() formula are only summing one unit at a time.

Maybe you need to post some example data of both the inputs and expected outputs - this link shows a few different ways to do that:

https://www.mrexcel.com/forum/about-board/508133-attachments.html



Thanks again FormR.

Inputs above are real numbers with the formula to extract that as well.

For precise output three precise examples are mentioned above.

Please advise if I am unable to explain it clearly please?

Thanks.
 
Upvote 0
Please advise if I am unable to explain it clearly please?

Are you trying to concatenate all the quantity and units into a single cell where the quantity returned from the SUMIF() is greater than zero?

If yes, does your version of Excel have the TEXTJOIN() formula available? Are there really just 6 different unit types that need conditionally concatenating?
 
Upvote 0
Are you trying to concatenate all the quantity and units into a single cell where the quantity returned from the SUMIF() is greater than zero?

If yes, does your version of Excel have the TEXTJOIN() formula available? Are there really just 6 different unit types that need conditionally concatenating?



Dear FormR,

Again thanks and much appreciated.

Yes, you are absolutely right, this is exactly what I am trying to achieve. Quantity and its relevant Unit concatenated if there is any value in Quantity.

Yes, in my version of XL I can see the TEXTJOIN() formula. Never used or known of it before, can you please guide / advise to get me where I want to be please.

Thanks,
 
Upvote 0
Dear FormR,

Again thanks and much appreciated.

Yes, you are absolutely right, this is exactly what I am trying to achieve. Quantity and its relevant Unit concatenated if there is any value in Quantity.

Yes, in my version of XL I can see the TEXTJOIN() formula. Never used or known of it before, can you please guide / advise to get me where I want to be please.

Thanks,



==========================

Dear FormR,


With your suggestion I tried TEXTJOIN() as follows: =TEXTJOIN(" ",TRUE,B82:C87)


The Result is as follows: 1219 PCS, 1377 KGS, 2688 SET, 0 YDS, 1100 MTR, 2390 PAR,


FROM B82 to C87 following are the values taken from sumifs():
1219 PCS
1377 KGS
2688 SET
0 YDS
1100 MTR
2390 PAR


Now I am unable to figure out how I hide or remove "0 YDS" from the result because there is no value in it so it shouldn't be there.

Please guide / advise.

Thanks.



[TABLE="width: 269"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD="align: right"][/TD]
[TD]

[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Hi, I can't test this as I don't have a new enough version of Excel where I am today but you could try this:

=TEXTJOIN(", ",TRUE,IF(B82:B87>0,B82:C87))

This is an array formula and you need to commit it using CTRL+SHIFT+ENTER - google will help if you need more information on how to enter array formula in Excel.
 
Upvote 0
Hi, I can't test this as I don't have a new enough version of Excel where I am today but you could try this:

=TEXTJOIN(", ",TRUE,IF(B82:B87>0,B82:C87))

This is an array formula and you need to commit it using CTRL+SHIFT+ENTER - google will help if you need more information on how to enter array formula in Excel.




I just tried and the result is:

1219 PCS, 1377 KGS, 2688 SET, FALSE FALSE 1100 MTR, 2390 PAR,

Again the same problem, how may I remove / hide the "FALSE FALSE" now. Any suggestions please?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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