I statement using string value in Column expression

DR/CR Column contains = Dr and Cr string value
ABS=Sales

If (column(“DR/CR”) = “Dr”)
{column(“ABS”)}
else {0}

I want to separate the sales of Dr and Cr into 2 columns

Hello @seanmanzanilla
Try by using ‘Pivoting’ node. Configured with [DR/CR] in Pivots and [ABS] in Manual aggregation aggregated by Sum or Mean… depending on data configuration an desired results (double check on expected results before validating your workflow)

BR

2 Likes

Hi @seanmanzanilla,

As @gonhaddock has said, the pivot node could be used to aggregate/summarize your debits and credits into two columns.

Alternatively, if your requirement is to simply include additional Debits and Credits columns to your existing data set you can also chain a pair of Rule Engine nodes:


(ignore the strange colour formatting in the above - it is confused by the “/” in the column name, but it doesn’t affect its operation.)
image

image
becomes:
image

Or, you could leave out the TRUE => 0 line, in which case it would show missing values instead of zeroes where a value it is not applicable to each column.

split column.knwf (8.3 KB)

So it depends on your use case as to which method is appropriate, but I hope that helps.

2 Likes

Yes @takbb ,
I oversighted it on this comment, Pivoting will change the structure of the data, meanwhile your approach honors the initial structure.

It usually happens when the description of the challenged task is focused in the functionality without a context.

BR

2 Likes

Hi @gonhaddock , I think your approach and suggestions are perfectly valid and it’s always good to raise awareness of the pivoting and unpivoting nodes which can be an extremely powerful tool :slightly_smiling_face:

2 Likes

I love your idea, i think it will work on my future project

1 Like

This idea works for me thank you!

2 Likes