Using ConcatenateX with other function to ignore blank values

naveeddil

New Member
Joined
Nov 5, 2015
Messages
46
Office Version
  1. 365
Platform
  1. Windows
Dear Experts,

To get unique and summarize result of a value in pivot tables i am using below command in to get distinct values from the data.

Excel Formula:
=CONCATENATEX(VALUES(Table1[ModalityCode]), Table1[ModalityCode] ,", ")

and i get the output as APPLES, ORANGES

As the data is very lengthy and there are suppose to be blanks values in the [ModalityCode] and it wasn't there in some months, so when there are blank values in start or end of the data so then i get the data as

, APPLES, BANANA
, APPLES
ORANGES, APPLES,
BANANA,
APPLES,


I want to customize the above CONCATENATEX and to eliminate the initial or ending delimeter if there are blank values.
 
Last edited:

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
It doesnt make sense but let me mention that i used below
Excel Formula:
=IF(ISBLANK(Table1[ModalityCode]),"",CONCATENATEX(VALUES(Table1[ModalityCode]), Table1[ModalityCode] ,", "))

and got the error that "This formula is invalid or incomplete: 'Calculation error in measure 'Table1'[ModalityJoINT]: A single value for column 'ModalityCode' in table 'Table1' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.'."
 
Upvote 0
Actually it does make sense since you passed an entire table column as the first argument of an IF function, and you can't do that. Try filtering your table:

Excel Formula:
=CONCATENATEX(VALUES(FILTER(Table1[ModalityCode],NOT(ISBLANK(Table1[ModalityCode])))), Table1[ModalityCode] ,", ")
 
Upvote 0
Thanks for the response.

Its having almost same error.

This formula is invalid or incomplete: 'Calculation error in measure 'Table1'[ModalityJoINT]: A single value for column 'ModalityCode' in table 'Table1' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.'.
 
Upvote 0
Apologies, I put the FILTER in the wrong place:

Excel Formula:
=CONCATENATEX(FILTER(VALUES(Table1[ModalityCode]),NOT(ISBLANK(Table1[ModalityCode]))), [ModalityCode] ,", ")
 
Upvote 0
Apologies, I put the FILTER in the wrong place:

Excel Formula:
=CONCATENATEX(FILTER(VALUES(Table1[ModalityCode]),NOT(ISBLANK(Table1[ModalityCode]))), [ModalityCode] ,", ")
Sorry i got delayed as i had issues installing in XL2BB to attach the sheet
As evident in below tables, its still showing trailing commas


Sample ConcatenateX.xlsx
ABCDE
3RegionPROVINCEYearMonthModalityJOINT
4Region XProvince 22021Jan, Inaccessbile
5Region XProvince 22021Feb
6Region XProvince 22021Mar, Inaccessbile
7Region XProvince 22021Jun, Inaccessbile
8Region XProvince 22021NovM2M
9Region XProvince 22021DecInaccessbile
10Region XProvince 22022Jan, M2M, Mix
11Region XProvince 22022FebInaccessbile
12Region XProvince 22022Mar, Others, H2H
13Region XProvince 22022May, Others, Inaccessbile, H2H
14Region XProvince 22022Jun, Others, H2H
15Region XProvince 22022Jul, Others, H2H
16Region XProvince 22022Sep, Others, H2H
17Region XProvince 22022Oct, Others, H2H
18Region XProvince 22022Dec, Others, H2H
19Region XProvince 22023JanH2H, Others,
20Region XProvince 22023MarOthers,
21Region XProvince 22023MayOthers,
22Region XProvince 22023JulOthers,
23Region XProvince 22023AugOthers,
24Region XProvince 22023SepOthers,
25Region XProvince 22023OctOthers,
26Region XProvince 22023NovOthers,
27Region YProvince 12021Jan, Inaccessbile, H2H
28Region YProvince 12021Mar, Inaccessbile, H2H
29Region YProvince 12021Jun, Inaccessbile, H2H
30Region YProvince 12021Nov, H2H
31Region YProvince 12021Dec, H2H
32Region YProvince 12022Jan, H2H, Others
33Region YProvince 12022Feb, H2H, Others
34Region YProvince 12022Mar, H2H, Others
35Region YProvince 12022May, H2H
36Region YProvince 12022Jun, H2H
37Region YProvince 12022Jul, H2H
38Region YProvince 12022Sep, H2H
39Region YProvince 12023MarH2H, Others,
40Region YProvince 12023MayH2H,
41Region YProvince 12023AugH2H,
42Region YProvince 12023SepH2H,
Province
 
Last edited:
Upvote 0
It worked for me so I'd have to assume your codes are not actually blank.
 
Upvote 0
There are blank in some months as We have not activities during some months thats why when it concatenate so there are blanks
 
Upvote 0

Forum statistics

Threads
1,223,311
Messages
6,171,347
Members
452,397
Latest member
ddneptune

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