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

set expression is not working

I want to calculate the "Population" of a "Country" at "minimum Year".

PFA - screenshot suggest the min year is 1960. So, I want to calculate sum of population at 1960 of a country. please note that country is selected from a list box.

I am using this expression and it is not working:

=sum({<YearPopulation={"=(min(num#(YearPopulation)))"}>}Population)

But when I put =(min(num#(YearPopulation))) in a text box it returns 1960. I am not sure what I am doing wrong in Set Analysis expression. Can you please help?

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Try

=sum({<YearPopulation={'$(=(min(num#(YearPopulation))))'}>}Population)


i.e. a dollar sign expansion to evaluate the min() function.


It would also be good to transform the YearPopulation field from text to number in the script.

View solution in original post

6 Replies
Frank_Hartmann
Master II
Master II

can you share a sample and what is the expected output?

maxgro
MVP
MVP

try

sum({$ <YearPopulation={$(=min(YearPopulation))}>} Population)

swuehl
MVP
MVP

Try

=sum({<YearPopulation={'$(=(min(num#(YearPopulation))))'}>}Population)


i.e. a dollar sign expansion to evaluate the min() function.


It would also be good to transform the YearPopulation field from text to number in the script.

trdandamudi
Master II
Master II

Give a try on the below expression:


=sum({<YearPopulation={"$(=min(num#(YearPopulation)))"}>}Population)

sunny_talwar

It seems that your YearPopulation is read as text and not Year field. I would suggest converting it to Year in the script like this:

LOAD Year(Date#(YearPopulation, 'YYYY')) as YearPopulation

and then you can try this:

=Sum({<YearPopulation={"$(=Min(YearPopulation))"}>} Population)

In case making modification in the script isn't possible, you can try MinString which will find the Min of Text String:

=Sum({<YearPopulation={"$(=MinString(YearPopulation))"}>} Population)

Not applicable
Author

Thank you so much!