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

GetFieldSelections - MonthYear

Hey Guys,

I'm trying to pull a list of MonthYear and convert it to a number of the monthstart.

subfield(GetFieldSelections(MonthYear, ';'), ';',1)

Once I get it to this point it brings in the first MonthYear selected it is then converted to text. For example, (Jan-2010) but I need it as 40209 (1-31-2010).

I have tried wrapping date and num around it but then I get null.

I thought about doing a left 3 to grab the month and then a right 4 to grab the year. Then using makedate, but the month isn't a number.



1 Solution

Accepted Solutions
johnw
Champion III
Champion III

Your only problem might be that you need to wrap date#() instead of date():

num(date#(subfield(GetFieldSelections(MonthYear, ';'), ';',1),'MMM-YYYY'))

I think this would give the same result more efficiently, assuming MonthYear is sorted ascending (otherwise use max):

if(getselectedcount(MonthYear),num(min(MonthYear)))

Or if you don't mind taking the min of all possible values when nothing is selected:

num(min(MonthYear))

View solution in original post

2 Replies
johnw
Champion III
Champion III

Your only problem might be that you need to wrap date#() instead of date():

num(date#(subfield(GetFieldSelections(MonthYear, ';'), ';',1),'MMM-YYYY'))

I think this would give the same result more efficiently, assuming MonthYear is sorted ascending (otherwise use max):

if(getselectedcount(MonthYear),num(min(MonthYear)))

Or if you don't mind taking the min of all possible values when nothing is selected:

num(min(MonthYear))

Not applicable
Author

Thanks John! date# worked!