Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join us for a live Q&A! September 21, 10 AM ET - Onboarding Fast in Qlik Sense SaaS! REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
nehapathak
Contributor II
Contributor II

Change in text color expression in Qliksense

Hi All,

I have attached a QVF file.

I Have a table with customers and count of employee id corresponding to those customers.

I have created a variable named max_date which basically calculate the maximum date from date field.


when the app is opened for the very first time then the data is displayed w.r.t. the max date i.e. Dec i.e nothing is selected from the date filter.

My requirement is that when the app is opened and data is displayed corresponding to max date i.e. December then my text color should be black.

when I select any date from date filter then my text color should changed as follows:

If current count of emplid > previous selected date count of emplid then Red.

If current count of emplid > previous selected date count of emplid then green.

Problem I m facing while using the expression I have created i.e.

if(GetSelectedCount(reportdate)=0,black(),

if(GetSelectedCount(reportdate)=1, if(count({$}Empid) > Count({$1}Empid),red(),Green() ))

)

is on first selection of date from date filter the current count of emplid is compared with the total count of all the dates and give color accordingly which is wrong.

For eg. if for first time I select October then count corresponding to October is being compared with the count of Dec, Nov, Oct.

What is want is that when on first selection I select October then the October count should be compared with max date i.e. max_date variable data and on next selection the current filter selection count  should be compared with the previous selected filter date and should give colors accordingly.

Kindly Help.

Thanks In advance.

17 Replies
pooja821
Creator
Creator

stalwar1‌ Kindly help on this one..

pooja821
Creator
Creator

luismadriz‌ Kindly help on this one....please.

divyanshi
Contributor III
Contributor III

shraddha.g‌ Kindly help...

sunny_talwar

Not entirely sure, but may be this

If(GetSelectedCount(reportdate) = 0, Black(), If(GetSelectedCount(reportdate) = 1, If(Count({$}Empid) > If(Count(TOTAL {$1}Empid) = 0, Count({<Date = {"$(=$(max_date))"}>} Empid), Count({$1}Empid)), Red(), Green())))

nehapathak
Contributor II
Contributor II
Author

on first selection it is showing all in green color but not comparing with the default max date

but for second selection onwards its working fine

sunny_talwar

My bad, try this

If(GetSelectedCount(reportdate) = 0, Black(), If(GetSelectedCount(reportdate) = 1, If(Count({$}Empid) > If(Count(TOTAL {$1}Empid) = 0, Count({<reportdate = {"$(=$(max_date))"}>} Empid), Count({$1}Empid)), Red(), Green())))

pooja821
Creator
Creator

its again comparing with total value but not with the default max value....thats why showing in all green colors..

We want is that when we select any value from report date filter for first time then as previous selected value was by default max date, then the current selected value should be compared with the previous date selected value(default max date)

Though after first selection the cycle is working fine..

sunny_talwar

I see the problem... the problem is not the expression, its the way Qlik Sense's selection works... To make a change in selection, you have to make two selections. First you deselect what is already selected and then you select what you want to (or the other way around). For some reasons, they are considered two selections. May be you want to go back two selections with $2 instead of $1

sunny_talwar

This

If(GetSelectedCount(reportdate) = 0, Black(), If(GetSelectedCount(reportdate) = 1, If(Count({$}Empid) > If(Count(TOTAL {$2}Empid) = 0, Count({<reportdate = {"$(=$(max_date))"}>} Empid), Count({$2}Empid)), Red(), Green())))