$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: false, vro: false, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content
0

Concatenate Rows excluding null from another column on the same line

Jan 17, 2017 at 12:38 AM

34

avatar image
Former Member

Hi

i am trying to concatenate strings from a number of rows but only where another column on the line is not null. Here is below what i have so far

//formula_NameOfPerson
if {job} = "" then "" else {name}
//formula_header

WhilePrintingRecords; 
StringVar Array reset; StringVar Array names:=reset; True; 
//formula_detail

WhilePrintingRecords;
StringVar Array names;
Redim Preserve names[Ubound(names)+1];
names[Ubound(names)]:=trim({@formula_NameOfPerson});
//formula_footer

StringVar Array names;Join(names, ",");
WhilePrintingRecords;

Currently the output is occuring

John,Sarah,,,,,,David,,,,Mike,,,,,,,,Sam,,,

what i want to it output is

John,Sarah,David,Mike,Same

Any advice would be much appreciated.

kind regards

David

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Abhilash Kumar
Jan 17, 2017 at 08:47 AM
1

Hi David,

Modify the 'formula_detail' as:

WhilePrintingRecords;
StringVar Array names;
if (NOT isnull({job}) OR {job} <> "") then
(
  shared numbervar cnt := cnt + 1;
  Redim Preserve names[cnt];
  names[cnt]:=trim({name});
)

'Formula_header' would be:

WhilePrintingRecords; 
StringVar Array names:='';
shared numbervar cnt := 0;
'';

Formula_footer would be:

WhilePrintingRecords;
StringVar Array names;
Join(names,",");

-Abhilash

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 18, 2017 at 04:41 AM
0

Hi Abihlash,

Thank you its almost working. The output is comming as John,Sarah,David,Mike,Sam on page 1 but the next pages (groups) the following is occuring

Page 2 = ,,John,Sarah,David,Mike,Sam

Page 3 = ,,,John,Sarah,David,Mike,Sam

Page 4 = ,,,,,John,Sarah,David,Mike,Sam

It is adding more and more ,,, as each group occurs. Is there a way to reset on each group?

Share
10 |10000 characters needed characters left characters exceeded
Abhilash Kumar
Jan 18, 2017 at 07:30 AM
0

Move the 'formula_header' to Group Header.

-Abhilash

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 18, 2017 at 08:13 PM
0

Hi Abhilash,

Thank you. My mistake.

Share
10 |10000 characters needed characters left characters exceeded