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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
hiringel
Contributor III
Contributor III

Concatinate aggregated values

Hi,

In my transformation layer, I am trying to create a new country with values from the other countries.

CustomerRiskTable:

YearMonthCountryCustomersRisk
201701Norway2016820%
201702Norway2017821%
201703Norway2019019%
201701Sweden11156

15%

201702Sweden1116016%
201703Sweden1120017%
201701Denmark55365%
201702Denmark55204%
201703Denmark55208%
201701Finland5523050%
201702Finland5560051%
201703Finland5680060%

I want to add 1 row for each YearMonth in this table, customers should be sum of the others, risk should be the average weighted by number of customers.

In pseudocode (not really code at all):

Concatenate CustomerRiskTable:

For each i in YearMonth;

i as YearMonth,

{'Nordic'} as Country,

sum(Customers) as Customers,

weightedAVG(Countries,Customers) as Risk

So it looks a little bit like this:

YearMonthCountryCustomersRisk
.............
201701Nordic920900,364847
201702Nordic924580,374222
201703Nordic937100,429641

Can anyone help me with this?

1 Solution

Accepted Solutions
sunny_talwar

May be this

Concatenate (CustomerRiskTable)

LOAD YearMonth,

     'Nordic' as Country,

     Sum(Customers) as Customers,

     Sum(Customers*Risk)/Sum(Customers) as Risk

Resident CustomerRiskTable

Group By YearMonth;

Capture.PNG

View solution in original post

1 Reply
sunny_talwar

May be this

Concatenate (CustomerRiskTable)

LOAD YearMonth,

     'Nordic' as Country,

     Sum(Customers) as Customers,

     Sum(Customers*Risk)/Sum(Customers) as Risk

Resident CustomerRiskTable

Group By YearMonth;

Capture.PNG