Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Change color of bar chart based on current selection(YTD Problem)

Hello,

I am changing the color of the bars in a Bar Chart based on a selection in 'Period Number'. This code below is working fine when selecting one or multiple 'Period Number(s)'.

=IF(GETPOSSIBLECOUNT([Period Number])<>COUNT({1}DISTINCT TOTAL [Period Number]),

IF(MATCH([Period Number],CONCAT(DISTINCT [Period Number],',')),

RGB(252,100,98), ARGB(85,252,100,98)))

Now i am trying to expand this code with my YearToDate function. So If variable vYTD = 1 he should change all colors of the bars witch are even or previous to the selection in 'Period Number'.

Example:

YTD is active and the Selected Period Number = 3

Period 1: Green

Period 2: Green

Period 3: Green

Period 4: Grey

Period 5: Grey

etc.

I've tried different options but got none of the working.. Options like: IF(vYTD = 1 AND vMaxPeriod <= GetFieldSelections([Period Number]), GREEN(), RED()))

Can someone please help me out? Thanks!

Marco

3 Replies
whiteline
Master II
Master II

Hi.

Could you upload the sample ? Or at least explain what is the vMaxPeriod, what are the dimensions of your chart.

Not applicable
Author

vMaxPeriode = MAX([Period Number])

Expression = MONEY(SUM({<[Period Number]=}>}[Sales Value), '€ #.##0,00;€ #.##0,00-')

Period number is basicly like month number.

The expression of changing the color is used to highlight the selected period in the barchart so the user knows at what periods he is looking. Now i have a YTD button with should highlight the periods 01, 02, 03, 04, 05, 06, 07. YTD is working fine but i can't get Qlikview to change the color when YTD is active.

Example.png

whiteline
Master II
Master II

Hi.

if(Only({<[Period Number]={'<=$(=Max(total [Period Number]))'}>} [Period Number]), red())