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

Add background color for an expression with conditions ??

Hi i am having a pivot table with a 3 expressions sum(metric), avg(upper) and avg(lower), the last two being the benchmarks to be applied to the sum(metric) to apply a background color.

there are also filters Browser,OS and Trip. When any of these filters are applied i dont want the color to change. But on an overall level i want the colors to be like

if(sum(Metric)>= Avg(Uppper),Green(),

                                          if(sum(Metric)<<Avg(Lower),Red())

                                          )

                               )

this works.

But when i  use

if(Browser = Null(),

               if(OS=Null(),

                              if(Trip=Null(),

                                               if(sum(Metric)>= Avg(Uppper),Green(),

                                                              if(sum(Metric)<<Avg(Lower),Red())

                        )

                                              )

                              )

      )

so that the color is applied only when there are no filters applied, it doesnt work. It doesnt show error but no bg color appears.

Please help me out. What is wrong and is there any alternate solution????

1 Solution

Accepted Solutions
Gysbert_Wassenaar

No selections means everything is selected. What your testing for is if a value in a field is a null value. What you probably want is something like:

if(getselectedcount(Browser) or getselectedcount(OS) or getselectedcount(Trip),

    null(),

    if(sum(Metric)>= Avg(Uppper),

        Green(),

        if(sum(Metric)<Avg(Lower),

            Red()

        )

    )

)


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
skokenes
Luminary Alumni
Luminary Alumni

Try replacing "Browser = Null()" with "getselectedcount(Browser)=0". Also, you can combine those 3 if statements into 1 using AND. so

if(getselectedcount(Browser)=0 AND getselectedcount(OS)=0 AND etc...

Gysbert_Wassenaar

No selections means everything is selected. What your testing for is if a value in a field is a null value. What you probably want is something like:

if(getselectedcount(Browser) or getselectedcount(OS) or getselectedcount(Trip),

    null(),

    if(sum(Metric)>= Avg(Uppper),

        Green(),

        if(sum(Metric)<Avg(Lower),

            Red()

        )

    )

)


talk is cheap, supply exceeds demand