Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Frank_Hartmann
Master II
Master II

dynamic axis

Hi Community,

I would like to create a dynamic sortorder axis in script.

that means that the sortorder should be linked to actual month.

If we have Month = 06 now, then for Sortorder it should be the last value (=12)

and Month = 07 should be the first value (=1) for sorting.

In the next month, 07 should be the last value for sorting (=12) and Month = 08

should be the first value (=1) for sorting!

I tried a for next loop in script, but i only managed  to get it work for seven values.

My script:

SET ThousandSep='.';

SET DecimalSep=',';

SET MoneyThousandSep='.';

SET MoneyDecimalSep=',';

SET MoneyFormat='#.##0,00 €;-#.##0,00 €';

SET TimeFormat='hh:mm:ss';

SET DateFormat='DD.MM.YYYY';

SET TimestampFormat='DD.MM.YYYY hh:mm:ss[.fff]';

SET MonthNames='Jan;Feb;Mrz;Apr;Mai;Jun;Jul;Aug;Sep;Okt;Nov;Dez';

SET DayNames='Mo;Di;Mi;Do;Fr;Sa;So';

test:

LOAD * INLINE [

    Month,

    01,

    02,

    03,

    04,

    05,

    06,

    07,

    08,

    09,

    10,

    11,

    12

];

For i = 0 to 11

test1:

Load

    Month,

    if(Month=Month(now())-$(i) and Month(now())-$(i)>0,12-$(i),if(Month-Month(now())-$(i)=0 and Month(now())-$(i)=0,12-$(i))) as Sortorder  

Resident test;

Next i;

DROP Table test;

  

ExpectedOutput:

LOAD * INLINE [

    MonthEO, SortoderEO

    01, 7

    02, 8

    03, 9

    04, 10

    05, 11

    06, 12

    07, 1

    08, 2

    09, 3

    10, 4

    11, 5

    12, 6

];

Any ideas how to achieve that for all 12 values?

Every help will be appreciated!

10 Replies
Frank_Hartmann
Master II
Master II
Author

Super, vielen Dank für deine Hilfe!