Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to select only one element based on another selection

Hi, I have a problem to create a button select an element from the result of another selection.

Target:

1. Select the latest "Date".

2. Based on the latest Date, the column Name can have multiple result.

3. Select only one Name from step 2.

Is there some thing like below:

somefunction({<Date={'$(=only(max({<Date={"<=01-10-2014 0:00:00"}>}Date)))'}>}Name)

that can select only one (the top one) Name from the Name list?

This is like to use array[1] in php, but I do not know how to select it in qlikview.

Can any one help?

THanks very much

1 Solution

Accepted Solutions
rubenmarin

Hi, for the Select Name Button you can select:

=MinString({<Date={'$(=only(Date))'}>}Name)

View solution in original post

13 Replies
german_avanzato
Creator
Creator

Hi,

If you need the "Name" field, one way could be a combination of aggr function with FirstSortedValue

FirstSortedValue(Name, -aggr(sum/max/rank({<Date={"<=01-10-2014 0:00:00"}>value),Name))

The expression is only an approach.

Anonymous
Not applicable
Author

@German,

Sorry, I made a mistake. It still dose not work.

It works only when the max(Date) and Name are 1-1 match. If for a max(Date), there are multiple value in Name column. Then the result is null.

german_avanzato
Creator
Creator

If you could upload and example of your model, maybe I can solve the problem.

aggr function is like a group by function.

Maybe, you need to add the Date into the dimmension

FirstSortedValue(Name, -aggr(sum/max/rank({<Date={"<=01-10-2014 0:00:00"}>value),Date,Name))

and/or use the rank function, to sort the result/limit it.

With and example of your model will be much easy to help you.

Anonymous
Not applicable
Author

Hi, All

Happy 2015!!

I still have this problem. My target is to have two buttons: 1st button is to select a Date (Step 1 in the example), and then run a macro to press the 2nd button to select the Name for the Name list box(Step 2 in the example ).

And attached is a example .qvw file.

Case 1:You can see when you click on button "SelectDateOneName",  and then click on button "SelectName", it works.

Case 2:But when you "SelectDateMultiName", then my solution dose not work.

I am wondering in case 2, how can I select all result and one result (only Name1, first one order by alphabet) in the "Name list box".

Thanks very much

Anonymous
Not applicable
Author

Hi, German,

Thanks for all your help. And happy new year.

I attached an example .qvw file.

Zhihong

rubenmarin

Hi, for the Select Name Button you can select:

=MinString({<Date={'$(=only(Date))'}>}Name)

Anonymous
Not applicable
Author

Hi, Ruben,

Thanks very much. Your suggestion works to select one Name out.

Do you know in case 2, how can I have all Name selected (Both Name1 and Name2)?

Thanks

ecolomer
Master II
Master II

Here you have an example.

When I select a project auto selected date max in other variable

rubenmarin

Hi, to select all names you can use:

='('&Concat({<Date={'$(=only(Date))'}>}Name,'|')&')'