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: 
coloful_architect
Creator II
Creator II

reference line of dimension does not work with grouped week x axis at line chart

I want to use makedate expression to create a reference line at line chart.

when it is calendar day x axis, it shows good like this .

coloful_architect_0-1693367922771.png

 

however, it does not work at x axis when I convert calendar day into week

coloful_architect_1-1693367973205.png

It took a bit time to realize that only when I turn "continuous" on, the reference comes back. but my week axis is gone.

 

coloful_architect_2-1693368036327.png

I use week function to convert the calendar day into week.

 

is there a way I can show the x axis with week label ( like the second label) but also have the reference line ? 

 

thanks 

 

Labels (2)
2 Solutions

Accepted Solutions
Javizh
Partner - Contributor III
Partner - Contributor III

Hello.

When you create a Dimension refference line, your "Dimension value" expresion should always return a value existing in the X axis.

With the Date axis, using a "Max(Date)"  or "Today()"  function should work.

But when you use the Week axis, you need an expression that returns a week value. For example "Only({<Date = {'$(=Date(Today()))'}>} Week)".

You cannot use the same expression for both axis unless its a continious axis, which you dont want.

PS: I used the "Today()" funcion, but you can replace it with the date you want.

Attached is an example.

Hope its helpful.

Best Regards.

View solution in original post

Javizh
Partner - Contributor III
Partner - Contributor III

Hello coloful_architect.

I see, I didnt catch you!

Then you need to do your Sales sum, only when the Date equals the last Date of each Week.

Transforming that to Set Analisys: 

  • sum( {< Date = {"=Date = Aggr(NODISTINCT Max(Date),Week)"}>} Sales)

Attached is the updated example with another sheet.

Hope I understood correctly this time.

Best Regards

View solution in original post

5 Replies
Javizh
Partner - Contributor III
Partner - Contributor III

Hello.

When you create a Dimension refference line, your "Dimension value" expresion should always return a value existing in the X axis.

With the Date axis, using a "Max(Date)"  or "Today()"  function should work.

But when you use the Week axis, you need an expression that returns a week value. For example "Only({<Date = {'$(=Date(Today()))'}>} Week)".

You cannot use the same expression for both axis unless its a continious axis, which you dont want.

PS: I used the "Today()" funcion, but you can replace it with the date you want.

Attached is an example.

Hope its helpful.

Best Regards.

coloful_architect
Creator II
Creator II
Author

Javizh, it works like a charm!  Appreciate it.

 

I have a follow-up question ,hoping you could help me again.

 

now everything is grouped by week, at that chart of weekly axis, how can I only show the value as the last day of week rather than the sum aggregation of all days within single week ?

for example, the data table I have is 

day, week, sales

1         1          10

2         1           15

3         1            16

 

at line chart, I only want to the value label to show the day 3 's value of 16  rather than  10+15+16 ?

please advise.

 

Javizh
Partner - Contributor III
Partner - Contributor III

Hello coloful_architect.

Im happy it was helpful! 🙂

Regarding your second question, there is some options, but here is what I would do:

Having the week I want to represent, I would transform it into a variable:

  • vCurrentWeek  = "=Only({<Date = {'$(=Date(Today()))'}>} Week)"

Then, in the "Label" expression from the reference line, you need to sum your Sales field filtered by the max Date of that Week, which equals vCurrentWeek 

Transforming that to Set Analisys: 

  • sum({< Date = {'$(=Max({<Week = {'$(vCurrentWeek)'}>}Date))'}>}Sales)

Then you mark "Show label" and unmark "Show value" and that should show your expression with the value you are looking for.

Note that the "Dimension value" is unchanged but you can use your variable now that you created it.

Attached is the updated example with another sheet.

Hope its helpful.

Best regards.

 

coloful_architect
Creator II
Creator II
Author

much appreciated your prompt response. Javizh. you are way ahead of game..

actually I was looking for the measurement expression to show the last day value rather than reference line.

 

coloful_architect_0-1693419917947.png

for example , at your qvf, I want each week of the line to show the value of that last day in the week.

if you check the screenshot, I want 2023/31 to show 19,575 which is the value of day 6/8/23 rather than the sum aggregation of 112,617... what I should change at measurement expression? 

sorry I should be more specific. 

Javizh
Partner - Contributor III
Partner - Contributor III

Hello coloful_architect.

I see, I didnt catch you!

Then you need to do your Sales sum, only when the Date equals the last Date of each Week.

Transforming that to Set Analisys: 

  • sum( {< Date = {"=Date = Aggr(NODISTINCT Max(Date),Week)"}>} Sales)

Attached is the updated example with another sheet.

Hope I understood correctly this time.

Best Regards