Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
fabrice_lattern
Contributor III
Contributor III

Summing children amount on parent data

Hello everybody !

I am struggling to build an aggregate function. I have a kind of hierarchy in my data (without having define a hierarchy in the load script) :

DEAL_NUMBER, PARENT_DEAL_NUMBER, AMOUNT

Now, I am trying to build a pivot table with the DEAL_NUMBER as dimension, showing :

- The amount of the deal
- The amount of the children deals

I am trying to do something like this, but of course it does not work as my dimension in the pivot is the DEAL_NUMBER and not the PARENT_DEAL_NUMBER, and I do not know of to put this amount in front of the parent deal.

 

AGGR(SUM(AMOUNT), PARENT_DEAL_KEY)

 


Here is an example of what should be achieved

Data:

DEAL_NUMBERPARENT_DEAL_NUMBERAMOUNT
A 100
BA20
CA10

 
Result:

DEAL_NUMBERAMOUNTCHILDREN AMOUNT
A10030
B20 
C10 

 

Thanks in advance for any advice !

Labels (2)
3 Replies
sunny_talwar

Is it possible to assign the same DEAL_NUMBER to PARENT_DEALER_NUMBER when PARENT_DEALER_NUMBER is null or blank? What I mean is to do this in the script?

DEAL_NUMBERPARENT_DEAL_NUMBERAMOUNT
AA100
BA20
CA10

 

Once you do this, it becomes easy and you can do like this

If(DEAL_NUMBER = PARENT_DEAL_NUMBER,
  Sum(TOTAL <PARENT_DEAL_NUMBER> 
    If(DEAL_NUMBER <> PARENT_DEAL_NUMBER, AMOUNT
    )
  )
)

 

fabrice_lattern
Contributor III
Contributor III
Author

Hello,

First of all, thanks for your answer.

I do not think it is feasible. I am going to explain a bit more the context : we have some intercompany business (internal deals), then we sell our product to a end customer (external deals).

So sometimes we have internal deal (C) linked to internal deal (B) linked to external deal (A) (it is the max imbrication allowed, there is no four level hierarchy).

DEAL_NUMBERPARENT_DEAL_NUMBERTYPOLOGYAMOUNT
A EXTERNAL1000
BAINTERNAL100
CBINTERNAL20

 

I still have the same requirement :  sum the amount of deal C in front of deal B (for some intercompany margin elimination purpose), but deal B has already a parent deal number (A), that I cannot change.

And if I use a technical field I guess it will be missleading for the report users.  

sunny_talwar

May be you need to set this up as a Hierarchy load in the script?