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: 
stekol61
Creator
Creator

Sort year-week in graph

 

Hi!

I have a graph that can present data per month or per week.

For week, this expression is used
Year(inc_create_date)&'-'& Week (inc_create_date)as Week,


The graph uses this sort expression:
Sort by expression:
=Max(Month(inc_create_date))

But the sorting in the graph is not correct.

How can this be solved?

sort week.PNG

 

9 Replies
sunny_talwar

How about if you create your week field like this

Dual(Year(inc_create_date)&'-'& Week (inc_create_date), WeekStart(inc_create_date)) as Week,

and then sort it numerically

pradosh_thakur
Master II
Master II

try sorting with

by expression
num(weekstart(inc_create_date))

by number/numeric sort

use expression as
dual(Year(inc_create_date)&'-'& Week (inc_create_date)as Week, num(weekstart(inc_create_date)))

Learning never stops.
stekol61
Creator
Creator
Author

Hi!

After a closer check I notice that the x-axis dimension uses a Master item object (=[$(vDim)]).

I think is uses Week and Month from this:
Dims:
LOAD
Dim,
RowNo() as DimSort
INLINE [
Dim
Week,
Month
];

Not sure if your suggestion still can be used?

sunny_talwar

I believe it should work... can you give it a shot.

stekol61
Creator
Creator
Author

The result looks a little different but still not OK

sort week2.PNG

sunny_talwar

Is this view based on a selection? If it is, do you have set analysis in your expression to ignore selection in Week field or any other date and time field?

stekol61
Creator
Creator
Author

Hi!

The selection used is 'Week'. The graph should be able to show 'Week' or 'Month' data base on a selection.
That's why the Master item and the Dims load is used

sunny_talwar

I understand that... but I am not sure what all do you select in your dashboard except for selecting Dim.... would you be able to share  a sample so that we can see your issue?

stekol61
Creator
Creator
Author

Hi!

Changed the MonthNames from jan.;feb.;mars;...... to 1;2;3;....
Then sorted the x-axis 'Alphabetically'
This seems to solve the problem with sorting for both Week and Month