Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
FelipeG
Contributor II
Contributor II

Sum Field based on other two fields aggregated

Hello Qlik community !! 

I have a table consisting of 4 Fields: Date, Buyer, Seller, TotalAmount. 

My data consists of transactions between the buyers and sellers which can be interchangeable, in other words, entity X can appear both as seller and buyer. What i want to do is rank the buyers and sellers as a single entity  "Company" based on the Sum of the total amount, whether they acted as buyer or seller. 

For example supposing I have this values in my Table:

DateBuyerSellerAmount
12/05/2020Apple Amazon2000
13/05/2019 AmazonApple2500
01/01/2020AppleMicrosoft1000

 

I want a table-chart that displays: 

RankCompanyTotal Amount Transactions
1Apple5500
2Amazon4500
3Microsoft1000

 

Will really appreciate it if someone can help me 🙂

 

1 Solution

Accepted Solutions
Kushal_Chawda

@FelipeG  may be you can create a model like below with creating Flag for Buyer and seller in case you want to look at the individually.

LOAD
    "Date",
    Buyer as Company,
    Amount,
    'Buyer' as Type
FROM [lib://Web]
(html, utf8, embedded labels, table is @1);

Concatenate

LOAD
    "Date",
    Seller as  Company,
    Amount,
    'Seller' as Type
FROM [lib://Web]
(html, utf8, embedded labels, table is @1);

 

Now you can create chart with Dimension company below measures

1) Sum(Amount)

2) rank(Sum(Amount))

View solution in original post

3 Replies
Kushal_Chawda

@FelipeG  may be you can create a model like below with creating Flag for Buyer and seller in case you want to look at the individually.

LOAD
    "Date",
    Buyer as Company,
    Amount,
    'Buyer' as Type
FROM [lib://Web]
(html, utf8, embedded labels, table is @1);

Concatenate

LOAD
    "Date",
    Seller as  Company,
    Amount,
    'Seller' as Type
FROM [lib://Web]
(html, utf8, embedded labels, table is @1);

 

Now you can create chart with Dimension company below measures

1) Sum(Amount)

2) rank(Sum(Amount))

FelipeG
Contributor II
Contributor II
Author

Thanks for the answer, this works fine. Is there a way I dont have to replicate my data? Right now I dont have big volumes of data but in the near future i might...

Kushal_Chawda

@FelipeG  Yes there is always a second way but that won't be flexible based on your requirements  otherwise I would have suggested it at first place