Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to get latest month from the data set

I have the data like in the month column

Jan

Feb

March

April

May......

Now I want latest month dynamically.

My Output should be Month= "May"

Thank you

Sujeeth

10 Replies
YoussefBelloum
Champion
Champion

Hi,

here is one way to do it:

you should have your MonthNames system variable like this:

Set MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';

max_month:

LOAD 1 as flag, Date#(month,'MMM') as month, num(month(Date#(month,'MMM'))) as monthnum Inline [

month

Jan

Feb

Mar

Apr

May

];

join

LOAD max(monthnum) as max_month

Resident max_month

Group by flag;

final:

NoConcatenate

LOAD * Resident max_month

Where monthnum=max_month;

DROP Table max_month;

PFA

eduardo_dimperio
Specialist II
Specialist II

LOAD

MONTH AS LAST MONTH

FROM YOURQVD

WHERE MONTH=MONTH(TODAY)

YoussefBelloum
Champion
Champion

your solution works only if you have the actual month in your dataset

eduardo_dimperio
Specialist II
Specialist II

yeap

Anonymous
Not applicable
Author

Hi,

I did it as below:

LOAD * INLINE [
MonthID, Month
1, Jan
2, Feb
3, Mar
4, Apr
5, May
6, Jun
7, Jul
8, Aug
9, Sep
10, Oct
11, Nov
12, Dec
]
;


Use these formulas:

=Max(Month) or

Month= Month(Today)

vkish16161
Creator III
Creator III

Sorting and using peek should be better I guess?

rubenmarin

Hi Sujeeth, you can try with:

=Month(Max(Date#(MonthField,'MMM')))

Anonymous
Not applicable
Author

Hi,

As of now in my excel sheet data contains only March and April data. My requirement is when ever the data loaded to my excel sheet it should take the latest loaded month dynamically.

Could you please help me on this.

Thank you

Sujeeth

rubenmarin

You can apply something very close to Youssef answer to keep the highest month of data:

Set MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';

Data:

LOAD Month(Date#(monthField,'MMM') as month,

  num(month(Date#(monthField,'MMM'))) as monthnum,

OtherFields

FROM [ExcelFile];

// Inner Join to keep only the max month

Inner Join (Data)

LOAD max(monthnum) as monthnum

Resident Data;