Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
michelle22
Contributor II
Contributor II

How to use WeekStart() within a colour set expression

Hi,

I'd like to denote a change in data collection method in a time series chart by changing the color of the line. Ideally I would've liked to create a vertical reference line (or bar) but that doesn't seem possible from what I've seen.

My X axis =WeekStart(Date)

I am able to get the color expression to work if I change the axis to just Date and use below, but the data needs to be represented by week.

=If(Date>='05/06/2023','color1','color2')

 

But this doesn't work with WeekStart. Is there a way to do this? I am open to alternative suggestions with how to best denote a change in data collection methods in this time series.

Labels (4)
1 Solution

Accepted Solutions
marcus_sommer

I suggest to create the week already within the calendar. Further you may there also creating a running week-number and/or an week-offset against today() and/or flags for past/future dates and/or if it goes against reload-related static values like today() even setting the colors there (a color is just a number).

Doing all such stuff within the UI is possible but doesn't makes it easier (mostly the opposite will happens).

View solution in original post

5 Replies
Chirantha
Support
Support

Hey Michelle,

 

You can try to use the WeekStart() function within a color set expression in Qlik Sense by using it in an if statement. 

 

Here’s an example:

 

=If(WeekStart(Date)>='05/06/2023', 'color1', 'color2')

 

This expression will change the color of the line to 'color1' if the week start date is greater than or equal to '05/06/2023', otherwise it will be 'color2'

rbartley
Specialist II
Specialist II

Hi,

It seems to work for me.  If you could post some example dates and a screenshot of where it's not working, it would help.

michelle22
Contributor II
Contributor II
Author

This doesn't seem to work for some reason. I've used

=If(WeekStart(Date)>='05/06/2023', 'red', 'blue')

 

michelle22_0-1688727458392.png

 

marcus_sommer

I suggest to create the week already within the calendar. Further you may there also creating a running week-number and/or an week-offset against today() and/or flags for past/future dates and/or if it goes against reload-related static values like today() even setting the colors there (a color is just a number).

Doing all such stuff within the UI is possible but doesn't makes it easier (mostly the opposite will happens).

michelle22
Contributor II
Contributor II
Author

Thanks, Marcus. I made a Week Start field in my Load Editor Calendar and then using the below worked perfectly:

=If([Week Start]>='05/06/2023', 'color1', 'color2')