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: 
Anonymous
Not applicable

Settting month order in scripting

Hi Genuises,

I have the months coming after loading the script are like below

Jun

Mar

Apr

May

I have to find the latest month and store in the variable in this case its Jun

I can use peek function like this trim(Peek('Month')); but the problem is the month order is not fixed,may be next month it will come like below

Jun

Aug

Apr

May

Mar

In this case I want Aug to store in variable.

Please help me

Thanks,

Shashank

11 Replies
jagan
Partner - Champion III
Partner - Champion III

Hi,

If you want create it in script then try below

TableName:

LOAD

Date(Date#(Month, 'MMM'), 'MMM') AS Month

'

'

'

FROM DAtaSource;

MaxMonth:

LOAD

Max(Month) AS MaxMonth

RESIDENT TableName;


LET vMaxMonth = Peek('MaxMonth',0,'MaxMonth');


DROP TABLE MaxMonth;


If you are this variable in script itself then this more useful, otherwise this is not best approach.  Create it in Front end itself


Settings -> Document Properties -> Variables.


Hope this helps you.


Regards,

Jagan.

Not applicable
Author

As we have in our Main tab in script editor, all the months listed in a variable MonthNames, we can associate a number to each of such a month and then find the max value of it.

You can try like:

vMyVar= chr(39) & Replace(MonthNames, ';', chr(39) & ',' & chr(39)) & chr(39);

TempMonth:
load  Month as MonthName,Match(Month,$(vMyVar))as MonthNumber ;
load * inline [
Month
'Jul'
'Aug'
'Dec'
'Feb'
'Mar'
]
;

Now you can find the max value from here.