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

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
brucemeyers
Contributor II
Contributor II

Population expression

I want to create an expression that summarizes the previous year population of each country without having to manually enter the year (i.e. 2017) at the beginning of each new year.

I got this far but I need help

Sum({$<[Country]={Germany}>}[Population])

   

Pot 1YearPopulation
Russia1/1/2018143,964,709
Russia1/1/2017143,989,754
Russia1/1/2016143,964,513
Germany 1/1/201882,293,457
Germany 1/1/201782,114,224
Germany 1/1/201681,914,672
Brazil 1/1/2018210,867,954
Brazil 1/1/2017209,288,278
Brazil 1/1/2016207,652,865
Portugal 1/1/201810,291,196
Portugal 1/1/201710,329,506
Portugal 1/1/201610,371,627
Argentina 1/1/201844,688,864
Argentina 1/1/201744,271,041
Argentina 1/1/201643,847,430
Belgium 1/1/201811,498,519
Belgium 1/1/201711,429,336
Belgium 1/1/201611,358,379
Poland 1/1/201838,104,832
Poland 1/1/201738,170,712
Poland 1/1/201638,224,410
France 1/1/201865,233,271
France 1/1/201764,979,548
France 1/1/201664,720,690
1 Solution

Accepted Solutions
felipedl
Partner - Specialist III
Partner - Specialist III

With your data, i did the following

load *,

Year(Year) as Num_Year;

load * Inline

[

Pot 1,Year,Population

Russia,1/1/2018,143964709

Russia,1/1/2017,143989754

Russia,1/1/2016,143964513

Germany,1/1/2018,82293457

Germany,1/1/2017,82114224

Germany,1/1/2016,81914672

Brazil,1/1/2018,210867954

Brazil,1/1/2017,209288278

Brazil,1/1/2016,207652865

Portugal,1/1/2018,10291196

Portugal,1/1/2017,11329506

Portugal,1/1/2016,12371627

Argentina,1/1/2018,44688864

Argentina,1/1/2017,44271041

Argentina,1/1/2016,43847430

Belgium,1/1/2018,11498519

Belgium,1/1/2017,11429336

Belgium,1/1/2016,11358379

Poland,1/1/2018,38104832

Poland,1/1/2017,38170712

Poland,1/1/2016,38224410

France,1/1/2018,65233271

France,1/1/2017,64979548

France,1/1/2016,64720690

];

And with the added field, I used it to get the current year for all selections and subtract one to get the last year.

sum

(

{<

Num_Year={"$(=Max(Total Num_Year)-1)"}

>}

Population

)

Getting:

sample.png

View solution in original post

1 Reply
felipedl
Partner - Specialist III
Partner - Specialist III

With your data, i did the following

load *,

Year(Year) as Num_Year;

load * Inline

[

Pot 1,Year,Population

Russia,1/1/2018,143964709

Russia,1/1/2017,143989754

Russia,1/1/2016,143964513

Germany,1/1/2018,82293457

Germany,1/1/2017,82114224

Germany,1/1/2016,81914672

Brazil,1/1/2018,210867954

Brazil,1/1/2017,209288278

Brazil,1/1/2016,207652865

Portugal,1/1/2018,10291196

Portugal,1/1/2017,11329506

Portugal,1/1/2016,12371627

Argentina,1/1/2018,44688864

Argentina,1/1/2017,44271041

Argentina,1/1/2016,43847430

Belgium,1/1/2018,11498519

Belgium,1/1/2017,11429336

Belgium,1/1/2016,11358379

Poland,1/1/2018,38104832

Poland,1/1/2017,38170712

Poland,1/1/2016,38224410

France,1/1/2018,65233271

France,1/1/2017,64979548

France,1/1/2016,64720690

];

And with the added field, I used it to get the current year for all selections and subtract one to get the last year.

sum

(

{<

Num_Year={"$(=Max(Total Num_Year)-1)"}

>}

Population

)

Getting:

sample.png