Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to do Computation after taggregate row

Based on group by and sum function from tAggregate row i got below output. Now i need to get a single amount 

 

Settled-Refund . Which component should be used

 

|=----------+--------=|
|TOTAL_PRICE|INDICATOR|
|=----------+--------=|
|4352.99 |SETTLED |
|650.46 |REFUND |'-----------+---------'

[statistics] disconnected

 

 

0683p000009M7sk.png

Labels (2)
1 Solution

Accepted Solutions
fdenis
Creator III
Creator III

it's easy to make calculation on one row.
so use tDenormalize ro have:
SETTLED | REFUND
4352.99 | 650.46

then use tmap.
good luck

View solution in original post

11 Replies
fdenis
Creator III
Creator III

it's easy to make calculation on one row.
so use tDenormalize ro have:
SETTLED | REFUND
4352.99 | 650.46

then use tmap.
good luck
Anonymous
Not applicable
Author

Can u pls elaborate on the same

Anonymous
Not applicable
Author

I assume you mean that you want to return the value of Settled-Refund on its own? If so, this can be done quite easily. I assume that Settled is always returned first? If so, you can extrapolate from this basic example. 

 

In this example I have the following flow. The tFixedFlowInput component returns one column with two rows. I am subtracting the second value from the first value. The subtraction takes place in the tMap.

 

0683p000009M7wb.png

Here is the tMap.....

0683p000009M7wg.png

Here I am making use of tMap variables. tMap variables have some very useful features. They are processed in order (top down) and they hold their values between rows. So, I have set up two Double values (the Nullable flag is set to true....this is important). The Record1 value is sent to the SecondValue variable and the SecondValue variable sets the value of the FirstValue variable. As these are set in order (top down), the first row will have the FirstValue variable set to NULL and the SecondValue variable set to the value of the first row. The second row will have the FirstValue variable set to the first row value and the SecondValue variable will be set to the second row value. The output filter on the Out1 output means that the first row value is not returned because we know that the FirstValue variable will always be NULL. Therefore we only return the second row and this will return the result of ....

Var.FirstValue-Var.SecondValue
Anonymous
Not applicable
Author

Its working thanks .But  a supercomplicated way to do a simple stuff ! 
Also this may not work if i need to aggregate  more rows with different Types . 

Isnt there a simpler  way to do it in Talend, I was looking for something like below : 

sum (row [INDICATOR='SETTLED'] /TOTAL_PRICE -row [INDICATOR='REFUND'] /TOTAL_PRICE)  

 

 

Can u suggest something else as well 

fdenis
Creator III
Creator III

using tDenormalize after taggregate is working fine even if you have multiple data to sum or to remove.
fdenis
Creator III
Creator III

what a dirty way…
Anonymous
Not applicable
Author

Sorry @fdenis, I wrote that before I saw your answer. I like to show off the functionality of the tMap, as it can massively help people with other computational problems. This method is ideal for comparing rows and only requires 1 component. However, your method was written first, so I will award the solution to you.

Anonymous
Not applicable
Author


@dkdarshu45 wrote:

Its working thanks .But  a supercomplicated way to do a simple stuff ! 
Also this may not work if i need to aggregate  more rows with different Types . 

Isnt there a simpler  way to do it in Talend, I was looking for something like below : 

sum (row [INDICATOR='SETTLED'] /TOTAL_PRICE -row [INDICATOR='REFUND'] /TOTAL_PRICE)  

 

 

Can u suggest something else as well 


@fdenis showed a simpler way of doing this. 

 

Given your example equation, you could approach this in many ways. However, you told us that you had two rows where the first row needed the second row subtracted from it. The method I gave is the most efficient way (a single component) I could think of at the time for achieving that. 

Anonymous
Not applicable
Author

I am not able to do using tdenormalize. Can u post snapshot of the same