Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
Qlik Connect 2025! Where innovative solutions turn your data visions into reality: REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
lessassy
Creator
Creator

Color on a bar chart based on value (value = date from master calendar)

Hello Everyone,

I'm using the master calendar in my script.

And I used that to display specific value based on weekyear (weeknumber and year)

Recent.PNG

What i want to do is to put in Green the most recent bar in the chart. The most recent one is 20.2018 and i want it to be in different color for comparison aspect.

I know i have to go to background in the expression view

color.PNG

But as i'm a newcomer for qlikview i don't know the right formula to put in order to have the bar chart in blue for the latest (most recent week).

As I previously said I have a master calendar in my script

MasterCalendar: 

Load 

               TempDate as Created, 

               week(TempDate) As Week, 

               Year(TempDate) As Year, 

               Month(TempDate) As Month, 

               Day(TempDate) As Day, 

               YeartoDate(TempDate)*-1 as CurYTDFlag, 

               YeartoDate(TempDate,-1)*-1 as LastYTDFlag, 

               inyear(TempDate, Monthstart($(varMaxDate)),-1) as RC12, 

               date(monthstart(TempDate), 'MMM-YYYY') as MonthYear, 

               ApplyMap('QuartersMap', month(TempDate), Null()) as Quarter, 

               Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear, 

               WeekDay(TempDate) as WeekDay 

And the field of the bar chart  (which represent the expression i used in the form (sum(LossBU))  is

field f.PNG

Anyone can help ?

Thank You

23 Replies
Janneke
Creator
Creator

Hi Yann,

I have looked at your qvw and encountered the issue that your WeekYear field is a string. So using Max() will not work. Instead, use MaxString.

However, since you have put the weeks in front of the year, week 9-2018 will be the max (since 9-.... is larger than 20-....).

Maybe you can fix this first by changing the calender putting year in front of week and then try the solutions mentioned above.

Greetings, Janneke.

lessassy
Creator
Creator
Author

Here is my modified master calendar:

MasterCalendar: 

Load 

               TempDate as Created,

               Year(TempDate) As Year,

               Month(TempDate) As Month,

               week(TempDate) As Week,               

               Day(TempDate) As Day, 

               YeartoDate(TempDate)*-1 as CurYTDFlag, 

               YeartoDate(TempDate,-1)*-1 as LastYTDFlag, 

               inyear(TempDate, Monthstart($(varMaxDate)),-1) as RC12, 

               date(monthstart(TempDate), 'MMM-YYYY') as MonthYear, 

               ApplyMap('QuartersMap', month(TempDate), Null()) as Quarter, 

               Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear, 

               WeekDay(TempDate) as WeekDay 

Resident TempCalendar 

Order By TempDate ASC; 

Drop Table TempCalendar; 

Here is a screenshot of the modificationgreen max.PNG

So If you are using a master calendar, could i have a sample where i could use min and max. I mean it's because of that that it's not working, right ?

Janneke
Creator
Creator

Hi Yann,

Try WeekYear(TempDate) & '-' & Num(Week(weekstart(TempDate)),'00') as WeekYear.

This will put the year in front and puts a zero in front of one-digit-weeks (9 --> 09). Sorting is then correct.

If you are not sure or it doesn't work, try testing parts of the expression (i.e. =MaxString(WeekYear)) in a text box, so you can understand how the definition is built.

Janneke.

lessassy
Creator
Creator
Author

Besides I have a cycle group in this chart (Weeks and Month) cycle group.PNG

What would be the exact formula to include month as well ?

lessassy
Creator
Creator
Author

Maxtringyear.PNG

It's working on a tex box but not on a bar chart.

It drives me crazy.

But so far progress was made and i thank you for that. Do you think it has to do with the bar chart property ?

Besides i wanted to ask you

I have a cycle group in this chart (Weeks and Month) cycle group.PNG

What would be the exact formula to include month as well ?

Thank you thank you

lessassy
Creator
Creator
Author

weekyeargreen.PNG

It work when i Specify the weekyear...

Janneke
Creator
Creator

Hi Yann,

Now you can put WeekYear in a variable:

vMaxWeekYear =MaxString(WeekYear)

Use this in the expression:

{<WeekYear={'$(=vMaxWeekYear)'}>}

Does this work?

Janneke

lessassy
Creator
Creator
Author

Sorry but i'm not very familiar for variable.

I added this in the scriptScript variable.PNG

But It doesn't appear neither in variable overview

variabel overview.PNG

nor in a set analysis within a text box...

Set analysis eror.PNG

lessassy
Creator
Creator
Author

I suceeded putting up the variable in the exact menus variable.PNG

Textbox var.PNG

But the text box doesn't recognize the variable as well 😕

Janneke
Creator
Creator

You need to use dollar sign: $(vMaxWeekYear).

If this is not working, then try to put =-sign in the variable: =MaxString(WeekYear)