3 Replies Latest reply: Jan 16, 2014 3:44 PM by whiteline _

# 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()))

Marco

• ###### Re: Change color of bar chart based on current selection(YTD Problem)

Hi.

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

• ###### Re: Change color of bar chart based on current selection(YTD Problem)

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.

• ###### Re: Change color of bar chart based on current selection(YTD Problem)

Hi.

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