Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
danosoft
Specialist
Specialist

Set Analisys take only the MAX month selected

Hi i have this set analisys to set my variable:

Set vFineMonthContrAlt = MonthEnd(MakeDate(GetFieldSelections(YEAR),Month(Date(Date#(GetFieldSelections(MONTH),'MM')))));

this take me the last day of my year month selected, for example if i select 2018 and 3 it will result: 31/03/2018

i wanna change it in this way:

if i select more months like 3,4,5   i want it result only the last day of the last month i selected, in this example so it must resutl: 30/05/2018

how can i set my variable for this?

thanks

21 Replies
danosoft
Specialist
Specialist
Author

Sorry if i write again but i need to put in the context and in the context it not work, look:

Set vFineMonthContrMaxMonth = MonthEnd(MakeDate(GetFieldSelections(ANNOOUT,';','','Contrattualizzato'),Month(Date(Date#(rangemax($(=GetFieldSelections(MESEOUT,',','','Contrattualizzato'))),'MM')))));

when in the text box i write:   =$(vFineMonthContrMaxMonth)

olivierrobin
Specialist III
Specialist III

where do you code your set instruction ?

the formula is designed to be used in UI

danosoft
Specialist
Specialist
Author

look the example i need to use my variable in the UI

olivierrobin
Specialist III
Specialist III

ok I see the problem

as you declare it in a set instruction, Qlik tries to interpret the $( when you construct your variable

so you have to replace set by let and to disconnect the $ of the (

achieve this by doubling all single quotes

and .....

let vFineMonthContrAlt=

'MonthEnd(MakeDate(GetFieldSelections(ANNOOUT,'';'','''',''Contrattualizzato''),Month(Date(Date#(rangemax(' & '$' & '(=GetFieldSelections(MESEOUT,'','','''',''Contrattualizzato''))),''MM'')))))';

danosoft
Specialist
Specialist
Author

but... can you explain to me why i need to enclosed it in $() for make rangemax work, and not only write GetfieldSelections withouth enclose in $()

thanks

danosoft
Specialist
Specialist
Author

but why if i do this expression it make me an error:

let vFineMonthContrAltSCADMaxMonth = 'MonthEnd(MakeDate(GetFieldSelections(ANNOOUT,'';'','''',''Contrattualizzato''),Month(Date(Date#(rangemax(' & '$' & '(=GetFieldSelections(MESEOUT,'';'','''',''Contrattualizzato'')))+1,''MM'')))))';

olivierrobin
Specialist III
Specialist III

where do you have an error .? and which one

I think +1 is misplaced

check you formula to see where you have to put it

olivierrobin
Specialist III
Specialist III

i think that without $, the formula is evaluated at compile time

$ forces QV to interpret it at run time

danosoft
Specialist
Specialist
Author

I see the problem is there :

let vFineMonthContrAltSCADMaxMonth = 'MonthEnd(MakeDate(GetFieldSelections(ANNOOUT,'';'','''',''Contrattualizzato''),Month(Date(Date#(rangemax(' & '$' & '(=GetFieldSelections(MESEOUT,'';'','''',''Contrattualizzato'')))+1,''MM'')))))';

it must be:

let vFineMonthContrAltSCADMaxMonth = 'MonthEnd(MakeDate(GetFieldSelections(ANNOOUT,'';'','''',''Contrattualizzato''),Month(Date(Date#(rangemax(' & '$' & '(=GetFieldSelections(MESEOUT,'','','''',''Contrattualizzato'')))+1,''MM'')))))';

why i need to replate this '';'' with '',''  if i use SET i need to write with '';''

olivierrobin
Specialist III
Specialist III

in all case, you need ','

look at rangemax syntax

its parameters are a list of values separated by commas