Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
mohdhaniff
Creator
Creator

Creation of Monthend/MonthsStart as Parameter in Let / Set Function

Hi,

I wish to create parameter value of MonthStart & MonthEnd, whereby value for 'From' and 'To' are formulated from value in 'Date' as below:

Set Date= '20170204';

Let From = Date(MonthStart(Date#($(Date),'yyyyMMdd')),'YYYY-MM-DD');
Let To = Date(MonthEnd(Date#($(Date),'yyyyMMdd')),'YYYY-MM-DD');



Expectation Result:


$(Date) = 20170204

$(From) = 2017-02-01

$(To) = 2017-02-28


Actual Result:


$(Date) = 20170204

$(From) = 2014

$(To) = 1987


Can anybody assist me to do the parameter set-up.

regards.

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Possibly your variable values are correct, only thing is while you are expanding them using $, they are getting evaluated, like:

$(From) = 2017-02-01 -> 2017 minus 02 minus 01 -> 2014

$(To) = 2017-02-28  -> 2017 minus 02 minus 28 -> 1987


Try not expanding them using $, but call directly without it (direct variable names) in another expression.

View solution in original post

2 Replies
Anil_Babu_Samineni

May be this?

SET Date = MakeDate(2017,02,04);

SET From =Date(MonthStart(Date(MakeDate(2017,02,04),'YYYY-MM-DD')),'YYYY-MM-DD');

SET End = Date(MonthEnd(Date(MakeDate(2017,02,04),'YYYY-MM-DD')),'YYYY-MM-DD');

If not, Try simple in text object and then see

OR

SET Date = Date(MakeDate(2017,02,04),'YYYYMMDD');

SET From = Date(MonthStart(Date($(Date),'YYYY-MM-DD')),'YYYY-MM-DD');

SET End = Date(MonthEnd(Date($(Date),'YYYY-MM-DD')),'YYYY-MM-DD')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
tresesco
MVP
MVP

Possibly your variable values are correct, only thing is while you are expanding them using $, they are getting evaluated, like:

$(From) = 2017-02-01 -> 2017 minus 02 minus 01 -> 2014

$(To) = 2017-02-28  -> 2017 minus 02 minus 28 -> 1987


Try not expanding them using $, but call directly without it (direct variable names) in another expression.