Aggregate Rows with logical question

Six Stars

Aggregate Rows with logical question

Hello. See my source table:

 

ProductUSUKCanada
XTRUEFALSETRUE
XFALSETRUETRUE
YFALSEFALSETRUE
ZFALSETRUEFALSE
YFALSEFALSEFALSE
XFALSETRUEFALSE

 

As you can see I have multiple rows for same product. Im trying to aggregate rows based on Product and the logic should be IF there is at least one row where Product/Country = TRUE then in aggregated result it is always TRUE, otherwise FALSE. I can see components like tAggregateRow where I can use some operations like sum, max, etc but I cant specify some logical question like I described.

So in the end Id like to have output table as follows:

 

ProductUSUKCanada
XTRUETRUETRUE
YFALSEFALSETRUE
ZFALSETRUEFALSE

 

Can anyone help? Thank you very much

Tags (1)
Highlighted
Six Stars

Re: Aggregate Rows with logical question

I created a simple job based on your sample table, using the "max" function of tAggregateRow and got the results you wanted.

aggregat.JPGaggregatedetail.JPGresult.JPG

Highlighted
Six Stars

Re: Aggregate Rows with logical question

How? I have tried that before but Im getting warning below:

The operation 'max' for the output column 'Canada' can't be processed because of incompatible input and/or output types (for each country)

From which I understood aggregate operations cant be ran on boolean or string

Highlighted
Six Stars

Re: Aggregate Rows with logical question

I have mine set up as string datatype for both input and output and it's working.

 

I am not sure how it would handle boolean, or if that is possible.

Highlighted
Community Manager

Re: Aggregate Rows with logical question

@cmendels, no function is available for boolean type, you get the right workaround, just convert the data from string to boolean type after aggregation if needed.
----------------------------------------------------------
Talend | Data Agility for Modern Business

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 3

Read about some useful Context Variable ideas

Blog