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

count(distinct(if(Reason=1,Reason))) expression cannot count how many reason ?

Hi All

I like to display the total number of Reason ?

Now my reason field have 10 reason. may i know how to display it on the count column.

I try below , but cannot work :-

count(distinct(if(Reason=1,Reason)))

Paul

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Your Reason field shows a '-' value, I misunderstood this as NULL.

So you need to filter this value:

=count({<Reason -= {'-'}>}Reason)

View solution in original post

8 Replies
paulyeo11
Master
Master
Author

Hi All

I need the count total = 9

Enclosed my QVF

swuehl
MVP
MVP

If you limit your Reason to Reason = 1, how should a distinct count of Reason show anything larger than One (or zero if Reason = 1 can't be found at all)?

I can't open your QVW at the moment, but if you want a count of your values and not a distinct count, then remove the DISTINCT qualifier.

paulyeo11
Master
Master
Author

Hi Stefan

You got the point. May i know how to check if the Reason field , have enter some text. now i assume Reason = 1 is wrong..

Paul

swuehl
MVP
MVP

What does a filter pane show?

paulyeo11
Master
Master
Author

Hi Stefan

I am not sure your question. As the filter panel does not display any thing , as i never select any filed. may be below image show you what is my issue.

display 1.png

swuehl
MVP
MVP

Maybe something like

=Sum( If( Len(Trim( Reason))>0,1,0))


Or


=Count(Reason)

paulyeo11
Master
Master
Author

Hi Stefan


Thank you very much for your sharing.

I try both your recommended expression , it display one , even those reason field is not fill with data. ( If you notice that first 4 row , the Reason field not enter any reasons , it should be 0 on the last 2 column ).

reasons.png

swuehl
MVP
MVP

Your Reason field shows a '-' value, I misunderstood this as NULL.

So you need to filter this value:

=count({<Reason -= {'-'}>}Reason)