Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
MishaM
Contributor II
Contributor II

Is there a way to choose only the first and last string values in a table?

Is there a way to choose only the first and last string values in a table?

Essentially, I need to create a title expression that shows the range of months. Also, as the months change, the data needs to update dynamically. The table I am using has a column titled Month and lists the last 4 months.

I tried using MaxString and MinString on the month column, but the data is being selected alphabetically so it is showing August as the MinString and September as the MaxString. I want it to show July as the Min and October as the Max.

I attached a small sample of the data.

Labels (2)
1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

If you interpret the months properly in the load script, like

SET LongMonthNames='January;February;March;April;May;June;July;August;September;October;November;December';
Data:
LOAD
Month(Date#(Month,'MMMM')) as Month,
Total_Machines_Total,
Total_Machines_Win10,
Total_Machines_Win7
FROM [Sample Data.xlsx] (ooxml, embedded labels, table is Sheet1);

then you will get the sort order right, and you can use

=MinString(Month) & '-' & MaxString(Month)

View solution in original post

3 Replies
hic
Former Employee
Former Employee

If you interpret the months properly in the load script, like

SET LongMonthNames='January;February;March;April;May;June;July;August;September;October;November;December';
Data:
LOAD
Month(Date#(Month,'MMMM')) as Month,
Total_Machines_Total,
Total_Machines_Win10,
Total_Machines_Win7
FROM [Sample Data.xlsx] (ooxml, embedded labels, table is Sheet1);

then you will get the sort order right, and you can use

=MinString(Month) & '-' & MaxString(Month)

MishaM
Contributor II
Contributor II
Author

Hi @hic ,

 

Thank you for the solution! The months are in the correct order now. However, is the month is showing as the first 3 letters of the month and not the full name for all of my tables now. Is there a way to show the long month name instead?

 

Thanks!

 

Misha

hic
Former Employee
Former Employee

Unfortunately you cannot use the format codes in the Month function directly, so the solution is a little more complicated. The following should do the trick

Dual(Month,Month(Date#(Month,'MMMM'))) as Month,