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: 
nikhilgarg
Specialist II
Specialist II

Prob in set analysis

Hey,

I want max month for selected year.

I used following set analysis but not working:

=max({<[Fiscal Year] = {$(subfield(GetCurrentSelections(), ':', 2))}>}[Trade Month])

Where am i wrong?

thanks

1 Solution

Accepted Solutions
swuehl
MVP
MVP

'It didn't worked' is not a very precise problem description.

What do you get when you put

=subfield(GetCurrentSelections(), ':', 2)


in a text box?


Since you are using GetCurrentSelections() I would only expect to get a year value back when the user is restricted to certain selections available.


In general, if you want the max Month for a certain selection, I would expect to get this by just something like:

=max( [Trade Month] )

View solution in original post

7 Replies
swuehl
MVP
MVP

If you want to use a dollar sign expansion with an expression, you need a leading equal sign:

=max({<[Fiscal Year] = {$(=subfield(GetCurrentSelections(), ':', 2))}>}[Trade Month])

svenkita
Creator II
Creator II

Check the Text Box in the example attached

nikhilgarg
Specialist II
Specialist II
Author

I tried this, but it didn't worked

nikhilgarg
Specialist II
Specialist II
Author

Hey,

Thanks but i have persoal editn , can you tell me here only

swuehl
MVP
MVP

'It didn't worked' is not a very precise problem description.

What do you get when you put

=subfield(GetCurrentSelections(), ':', 2)


in a text box?


Since you are using GetCurrentSelections() I would only expect to get a year value back when the user is restricted to certain selections available.


In general, if you want the max Month for a certain selection, I would expect to get this by just something like:

=max( [Trade Month] )

svenkita
Creator II
Creator II

Following is the script I have used in

SET ThousandSep=',';
SET DecimalSep='.';
SET MoneyThousandSep=',';
SET MoneyDecimalSep='.';
SET MoneyFormat='$#,##0.00;-$#,##0.00';
SET TimeFormat='h:mm:ss TT';
SET DateFormat='D/MM/YYYY';
SET TimestampFormat='D/MM/YYYY h:mm:ss[.fff] TT';
SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';
SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';

LET vDateMin  = Num(MakeDate(2013,4,1));
LET vDateMax  = Num(MakeDate(2016,3,11));

TempCalendar:
LOAD  $(vDateMin) + RowNo() - 1  AS DateNumber,
Date($(vDateMin) + RowNo() - 1) AS TempDate
AUTOGENERATE 1
WHILE $(vDateMin)+IterNo()-1<= $(vDateMax);

Star_Calendar:
Load
TempDate   As StarDate,
YearName(TempDate,0,4)  As StarFiscalYear,
if(index(yearname(TempDate,0,4),'-')>0,
subfield(yearname(TempDate,0,4),'-',2),
year(TempDate))  As StarFiscalBudgetYear,
'Q'&
if (Num(Month(TempDate)) = 4 , 1,
if (Num(Month(TempDate)) = 5 , 1, 
if (Num(Month(TempDate)) = 6 , 1, 
if (Num(Month(TempDate)) = 7 , 2, 
if (Num(Month(TempDate)) = 8 , 2, 
if (Num(Month(TempDate)) = 9 , 2, 
if (Num(Month(TempDate)) = 10 , 3, 
if (Num(Month(TempDate)) = 11 , 3, 
if (Num(Month(TempDate)) = 12 , 3, 
if (Num(Month(TempDate)) = 1 , 4, 
if (Num(Month(TempDate)) = 2 , 4, 
if (Num(Month(TempDate)) = 3 , 4, 
)))))))))))) 
As StarFiscalQuarter,
month(TempDateAs StarMonth,
Year(TempDateAs StarYear,
day(TempDateAs StarDay,
monthname(TempDateAs StarRollMonth,
week(TempDateAs StarWeek,
weekname(TempDateAs StarWeekName,
weekday(TempDateAs StarWeekDay,
if(weekday(TempDate)>=5,'WeekEnd','WeekDay')  As StarWeekEnd,
QuarterName(TempDate,0,4)  As StarQuarter
Resident TempCalendar
Order By TempDate ASC;
Drop Table TempCalendar;
LET vDateMin  = "";
LET vDateMax  = "";
LET vDateToday = "";

After loading the scrip...

create a list box for StarFiscalYear

Create a textbox with

=Month(Max(StarDate))
&
Chr(10) &
year(Max(StarDate))

on selection of a fiscal year on the listbox you will get the max Year and Month for the selected year

Kushal_Chawda

try,

max({<[Fiscal Year] = {"$(=subfield(GetCurrentSelections(), ':', 2))"}>}[Trade Month])