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: 
Not applicable

Display conditionally with count

Hi,

I have a simple question to which I can't seem to find the solution.

Is it possible to count some records and depending on this count display them in a ListBox.

Example:

I have a collection of numbers.

If a number appears more than once I want to display it in my ListBox.

If it only appears once I don't want that to happen.

It would be even better if this was possible like: "IF (Count(Numbers)>1, Display(Numbers))"

I thank anyone who answers in advance.

Dries

1 Solution

Accepted Solutions
Not applicable
Author

You can use the expression approach, but you will need to use the aggr() function.

=if(aggr(count(Field1),Field1)>1,Field1)

Take this sample inline table as an example:

LOAD * INLINE [

    Field1, Field2

    1, aaa

    1, aaa

    2, bbb

    3, bbb

    4, ccc

    4, ccc

    5, cdd

    6, cdd

    6, cdd

    7, eee

    8, eee

    8, eee

];

When I create a list box with the following expression, I get 1,4,6 and 8 in a list box.

=if(aggr(count(Field1),Field1)>1,Field1)

Hope that helps.

View solution in original post

5 Replies
kji
Employee
Employee

Make a listbox, select <expression> as field and put

=if(Count(Numbers)>1,Numbers,Null()) as the expression.

Not applicable
Author

I already came up with that but it doesn't seem to work for me.

Not applicable
Author

Make a straight chart with dimension Numbers. Make expression

if(count(Numbers)>1,count(Numbers))

Not applicable
Author

You can use the expression approach, but you will need to use the aggr() function.

=if(aggr(count(Field1),Field1)>1,Field1)

Take this sample inline table as an example:

LOAD * INLINE [

    Field1, Field2

    1, aaa

    1, aaa

    2, bbb

    3, bbb

    4, ccc

    4, ccc

    5, cdd

    6, cdd

    6, cdd

    7, eee

    8, eee

    8, eee

];

When I create a list box with the following expression, I get 1,4,6 and 8 in a list box.

=if(aggr(count(Field1),Field1)>1,Field1)

Hope that helps.

Not applicable
Author

It works.

Thanks a lot.