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

Showing exactly one of multiple possible values in table object

Hi,

in a table object I want to show exactly one of multiple possible values.

The dimension is KN_ID.

One KN_ID can have multiple OB_ID and therefore multiple values for OB_Type. In the Table I want to show OB_Type as a measure but I do not want to do any aggregation. I just want the column OB_Type to show one of the possible values for OB_Type for KN_ID.

So far I tried achieving that by using concat and other string functions, but I could not find a satisfying solution.

Could somebody help me with that?

Example is attached

Best regards and thanks in advance

thorben

1 Solution

Accepted Solutions
karthiksrqv
Partner - Creator II
Partner - Creator II

Ah..ok, then something like this

subfield(MaxString(len(OB_Type)&'|'&rand()&'|'&OB_Type),'|',3)

to ensure that strings with non-null values come up on top.

View solution in original post

13 Replies
OmarBenSalem

Hi Thorben,

The trick is to use Aggr( Min( KN_ID),OB_ID) instead of KN_ID as a dimension.

What does Aggr( Min( KN_ID),OB_ID) is taking the Min (so only one) KN_ID by OB_ID

See the attached app:

Capture.PNG

Anonymous
Not applicable
Author

Capture.PNG

Try using Maxstring(OB_Type ) as expression.

Not applicable
Author

okay, so maxstring does pick the last value (alphabetically ordered) of OB_Type?

This solution would be okay... But it would be great if the value selection would be more random.

Is there really no function to just randomly pick one of the values?

Not applicable
Author

thank you. I appreciate your response.

Unfourtunately, your solution does not work if you do not choose OB_ID as a dimension.

As the dimension is already complex enough in the real application, I would prefer not to change it.

Anonymous
Not applicable
Author

Am not sure what is the purpose of selecting a random value from the category?

Not applicable
Author

For example:

In the real application I have a field OB_Date. It is like OB_Type, so one KN_ID can have multiple values for OB_Date. If I use MaxString here it will always return the date which is nearest in the past. Such implications should not be made in the table, it should just show one value not always the biggest oder the smallest.

However if that is not possible I guess I will have to go with maxstring

Anonymous
Not applicable
Author

I wonder if there is any simple solution for your requirement. Lets see if some expert can help you out.

karthiksrqv
Partner - Creator II
Partner - Creator II

Hi Thorben,

This may work:

=subfield(MaxString(rand()&'|'&OB_Type),'|',2)

Not applicable
Author

I would have guessed it works but there are always some empty values in the resulting column...

Maybe if OB_Type is empty rand()&'|'&OB_Type is just the random number plus |. And then subfield returns an empty String.

I guess if OB_Type never was an empty string but null it should work. I am going to test it.