Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Not applicable

count expression

Hello community,

sorry, I couldn't think of a better title

I have various EnvNames in different files. Now I want to find out if EnvNames are missing in a file.

In below screenshot I have a straight table. I would like to change the background color of the 2nd column if the count

is below the count of all filenames.

So in this example only EnvA with a count of 4 would be green, the rest is red.

I can't figure out the if-statement to get this job done.

test.JPG

Hope you can help me out.

Thank you,

Thorsten

1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: count expression

Hi,

Try like this

=If(Count(Distinct FileName) = count(TOTAL DISTINCT FileName), Green(), Red())


Regards,

Jagan.

View solution in original post

8 Replies
MVP & Luminary
MVP & Luminary

Re: count expression

Hi,

Try like this

Chart Properties  -> Expressions -> Click on + symbol of expression and select Background -> Give this statement in that

=If(Count(Distinct FileName) = 4, Green(), Red())

If not working attach some sample file.

Hope it helps you.

Regards,

Jagan.

Partner
Partner

Re: count expression

bgColour.png

Not applicable

Re: count expression

both of you use the hardcoded 4. How can I change this into an expression?

If I use count(DISTINCT FileName) everything turns green. I also tried count( {1} [FileName]) without luck.

Partner
Partner

Re: count expression

count(total DISTINCT FileName)

MVP & Luminary
MVP & Luminary

Re: count expression

Hi,

Try like this

=If(Count(Distinct FileName) = count(TOTAL DISTINCT FileName), Green(), Red())


Regards,

Jagan.

View solution in original post

amarnathd
New Contributor III

Re: count expression

Hi,

Try this it will help you,

Chart Properties  -> Expressions -> Click on + symbol of expression and select text colour -> Give this statement in that

If(Count(Distinct FileName) = Aggr (Count(Distinct FileName),FileName), Red(),Green())

Hope this will work.

Thanks and Regards,

Amarnath

timanshu
Contributor III

Re: count expression

Hi Thorsten,

Do This:

Define a Variable

Example : vMax  =Max(aggr(Count(EnvName),EnvName))

Then,

In chart expressions , expression which gives count of EnvNames,   define its background as if(Count(EnvName)=vMax,Green(),Red()).

This Works.

timanshu
Contributor III

Re: count expression

Hi Thorsten,

Can you let me know how this expression worked:

=If(Count(Distinct FileName) = count(TOTAL DISTINCT FileName), Green(), Red())


or just attach qvw.

I am trying to make this work but it's not working.