8 Replies Latest reply: Apr 3, 2018 5:21 AM by Stefan Wühl

# 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

• ###### Re: count(distinct(if(Reason=1,Reason))) expression cannot count how many reason ?

Hi All

I need the count total = 9

Enclosed my QVF

• ###### Re: count(distinct(if(Reason=1,Reason))) expression cannot count how many reason ?

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.

• ###### Re: count(distinct(if(Reason=1,Reason))) expression cannot count how many reason ?

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

• ###### Re: count(distinct(if(Reason=1,Reason))) expression cannot count how many reason ?

What does a filter pane show?

• ###### Re: count(distinct(if(Reason=1,Reason))) expression cannot count how many reason ?

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.

• ###### Re: count(distinct(if(Reason=1,Reason))) expression cannot count how many reason ?

Maybe something like

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

Or

=Count(Reason)

• ###### Re: count(distinct(if(Reason=1,Reason))) expression cannot count how many reason ?

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 ).

• ###### Re: count(distinct(if(Reason=1,Reason))) expression cannot count how many reason ?

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

So you need to filter this value:

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