Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
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
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

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


Regards,

Jagan.

View solution in original post

8 Replies
jagan
Luminary Alumni
Luminary Alumni

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.

chrislofthouse
Partner Ambassador
Partner Ambassador

bgColour.png

Not applicable
Author

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.

chrislofthouse
Partner Ambassador
Partner Ambassador

count(total DISTINCT FileName)

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

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


Regards,

Jagan.

Anonymous
Not applicable
Author

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
Creator III
Creator III

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
Creator III
Creator III

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.