Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have the following code:
Temp:
Load Max(OrderDate) as MaxOrderDate Resident ORDER_2_CUST_SHIPPER;
Let currDate=Date(FieldValue('MaxOrderDate',1),'DD-MMM-YYYY');
Let currYear=Year($(currDate));
Drop Table Temp;
When I debug currYear is <NULL>.
I have also tried Let currYear=Year('$(currDate)'); but I get the same result.
If I try something like Let currYear=Year(Date(FieldValue('MaxOrderDate',1),'DD-MMM-YYYY'));
then I get the correct value, but this solution is not very dry.
Cheers ![]()
I figured it out ![]()
Way that it worked is:
Let currYear=Year(currDate);
But, I still do not understand completely how usage of $ works in QlikView, and it is strange, to say the least ![]()
In this case, $ did not work for Year function. In same script I had
Let prevYearDate = MakeDate(Year(Date(FieldValue('MaxOrderDate',1),'DD-MMM-YYYY'))
- 1,$(currMonth),$(currDay));
and it was working correctly. So, in Year function $ did not work and in MakeDate it did work...
My assumption was that no $ is used in script, and $ is used when calling script variables in expressions, but this MakeDate function working properly and Year not, is confusing.
So, if anyone has any idea why is it so please share ![]()
I figured it out ![]()
Way that it worked is:
Let currYear=Year(currDate);
But, I still do not understand completely how usage of $ works in QlikView, and it is strange, to say the least ![]()
In this case, $ did not work for Year function. In same script I had
Let prevYearDate = MakeDate(Year(Date(FieldValue('MaxOrderDate',1),'DD-MMM-YYYY'))
- 1,$(currMonth),$(currDay));
and it was working correctly. So, in Year function $ did not work and in MakeDate it did work...
My assumption was that no $ is used in script, and $ is used when calling script variables in expressions, but this MakeDate function working properly and Year not, is confusing.
So, if anyone has any idea why is it so please share ![]()
pl close this thread by marking a correct answer
If I mark it as answered then no one will bother to explain to me passing of variables to Year and MakeDate and why $ works in one and not another function.
I will wait for few days and then mark it as answered if no one bothers to answer.