Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Defaulting trend chart to show latest 4 weeks sorted assending

HI

I am trying to create a chart that automatically shows the latest 4 weeks.  I have managed to do this on the attached QVW by using

sum( {$<

DateNum = {"<=$(=vMaxDate)"}

,Date=

>} Qty)

However this only works if the data is sorted desending and i really want the trend chart to be assending ie oldest to newest date.  When i change the sort to asending it shows the oldest week not the latest 4.

In my example i really want the chart to show 29/1, 04/02, 11/02 and 18/02 but have the ability to change for peoples selections

Does anyone have any suggestions?

Thank you

1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

hei

the 21 means going 3 weeks back from the last week start which means its only selecting the last three week

what you did before was selecting all the weeks prior to the last week

an you put a trashhold of 4 on the values to show on the x-axis

but because you had more then 4 weeks i didnt give you the slected week

when you use the max values on the x-axis it give you the first 4 by the selected sort order

usually use this when you are sorting a chart by the y-value and you want to show only the best or worst resaults

hope it helps you

if the answer helped you mark it as a correct answer

so other users will know there is a solution to your question

View solution in original post

4 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    In sort try to change the sort order to Load Order.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
lironbaram
Partner - Master III
Partner - Master III

hei

attach is an example

you have two graphs

one is for the last four weeks abslut

and the seconed for the last four weeks from the selected Date

Not applicable
Author

Thank you this works - are you able to explain the logic behind it though?  why in the expression do you have vMaxDatev2-21 - what does the -21 do?

Thank you

lironbaram
Partner - Master III
Partner - Master III

hei

the 21 means going 3 weeks back from the last week start which means its only selecting the last three week

what you did before was selecting all the weeks prior to the last week

an you put a trashhold of 4 on the values to show on the x-axis

but because you had more then 4 weeks i didnt give you the slected week

when you use the max values on the x-axis it give you the first 4 by the selected sort order

usually use this when you are sorting a chart by the y-value and you want to show only the best or worst resaults

hope it helps you

if the answer helped you mark it as a correct answer

so other users will know there is a solution to your question