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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

List Box conditional Show

Hi all,

I need to create a List Box with few cities and I need to filter the cities that are not in Europe.

I have Longitude and Latitude for every city.

I have tried to use "If" like this:

=If(P_Longitude<=60 and P_Longitude>=11 and P_Latitude<=71 and P_Latitude>=36,1,0)

Obviously it did not work. can someone please help?

1 Solution

Accepted Solutions
settu_periasamy
Master III
Master III

you can try this expression in listbox.

=If(P_Longitude<=60 and P_Longitude>=11 and P_Latitude<=71 and P_Latitude>=36,'Europe','Others')


But instead of doing like this, you can do it in the script itself. Like


LOAD *,If(P_Longitude<=60 and P_Longitude>=11 and P_Latitude<=71 and P_Latitude>=36,'Europe','Others') as Region;
LOAD * INLINE [
P_Latitude, P_Longitude, Plant_ID, PlantName
-6.181015, 106.828335, 4, Jakarta
35.680071, 139.768522, 2, Tokyo
40.713054, -74.007228, 3, New York
51.507276, -0.12766, 6, London
52.374733, 4.898117, 1, Amsterdam
55.751615, 37.618701, 5, Moscow
]
;

Then simply create the 'Region' Listbox.

View solution in original post

8 Replies
sunny_talwar

Is this something you are thinking of doing on the front end of the script or back end?

sunny_talwar

May be like this on the front end:

Aggr(Only({1<Country ={'*'}-{'Europe'}>} City), City)

Not applicable
Author

First, thank you for you answer.

I did not understand it quite well, I am very new with this.

Let me write it again:

I have this table in Excel-

P_LatitudeP_LongitudePlant_IDPlantName
-6.181015106.8283354Jakarta
35.680071139.7685222Tokyo
40.713054-74.0072283New York
51.507276-0.127666London
52.3747334.8981171Amsterdam
55.75161537.6187015Moscow

And I need to create a chart only the cities in Europe.

sunny_talwar

You only have Longitude and Latitude? Don't have a field which explicitly states the name of the Country? Are you trying the if statement in the script to create flags?

settu_periasamy
Master III
Master III

you can try this expression in listbox.

=If(P_Longitude<=60 and P_Longitude>=11 and P_Latitude<=71 and P_Latitude>=36,'Europe','Others')


But instead of doing like this, you can do it in the script itself. Like


LOAD *,If(P_Longitude<=60 and P_Longitude>=11 and P_Latitude<=71 and P_Latitude>=36,'Europe','Others') as Region;
LOAD * INLINE [
P_Latitude, P_Longitude, Plant_ID, PlantName
-6.181015, 106.828335, 4, Jakarta
35.680071, 139.768522, 2, Tokyo
40.713054, -74.007228, 3, New York
51.507276, -0.12766, 6, London
52.374733, 4.898117, 1, Amsterdam
55.751615, 37.618701, 5, Moscow
]
;

Then simply create the 'Region' Listbox.

Not applicable
Author

I do not know what flag is.

but I am trying to show in a List Box only the rows that mach the If condition.

sunny_talwar

Does this look like what you want?

Capture.PNG

I created a flag in the script:

Table:

LOAD *,

  If(P_Longitude<=60 and P_Longitude>=11 and P_Latitude<=71 and P_Latitude>=36,1,0) as Flag;

LOAD * INLINE [

    P_Latitude, P_Longitude, Plant_ID, PlantName

    -6.181015, 106.828335, 4, Jakarta

    35.680071, 139.768522, 2, Tokyo

    40.713054, -74.007228, 3, New York

    51.507276, -0.12766, 6, London

    52.374733, 4.898117, 1, Amsterdam

    55.751615, 37.618701, 5, Moscow

];

And then used the following expressions for the two list boxes:

1) =Aggr(Only({1<Flag = {1}>} PlantName), PlantName)

2) =Aggr(Only({1<Flag = {0}>} PlantName), PlantName)

Not applicable
Author

Thank you all for you help!!!!!!!!!