Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
nareshthavidishetty
Creator III
Creator III

Variable error

Hi,

I have created an variable in script but it is showing an script error,but i have tested the same in text object its working fing fine.

Please find the below error.

Variable : let vCurr_Month_Year = month(monthstart(max(ActivityDate-1)))&' '&(year(max(ActivityDate-1)));

Untitled.png

Thanks..

38 Replies
nareshthavidishetty
Creator III
Creator III
Author

Hi,

vMax = ?

Thanks..

sunny_talwar

You want the variable to evaluated in the script? or do you want to bring it as an expression?

rubenmarin

Hi Naresh, I think the solution provided by tresesco should work, there is one parenthesys left:

LET vCurr_Month_Year = month(monthstart($(vMaxDate)))&' '&(year($(vMaxDate)));


Just to comment, why a month(monthstart(maxdate))?, I think it should be the same as Month(maxdate), no need for the monthstart.

nareshthavidishetty
Creator III
Creator III
Author

Hi,

The current variable is static like it give only month(max(today()) but now we need it as dynamic so that based on the year it should be react..

Thanks..

rupamjyotidas
Specialist
Specialist

I don't know your intent here but if you want to find out currentmonthyear

try this below code

temp_Min_Max_Dates:

LOAD

    Min(YourDate) as MinDate,

    Max(YourDate) as MaxDate

RESIDENT FWRSData

;  

Let vMinDate = Num(Peek('MinDate', 0, 'temp_Min_Max_Dates'));

Let vMaxDate = Num(Peek('MaxDate', 0, 'temp_Min_Max_Dates'));

Drop Table temp_Min_Max_Dates;

//Current Date

Let vReportCurrentDay           = 'Day($(vMaxDate))';

Let vReportCurrentMonth          = 'num(Month($(vMaxDate)))';

Let vReportCurrentYear              = 'Year($(vMaxDate))';

gireesh1216
Creator III
Creator III


vMax=max(ActivityDate)

nareshthavidishetty
Creator III
Creator III
Author

Hi,

Please let me know the below that variable is not working and is there any way to get this.

let vMax=MonthName(max(ActivityDate));

Thanks..

rubenmarin

Hi naresh, tresesco explained why that can't work in the first answer... and how to solve it.

nareshthavidishetty
Creator III
Creator III
Author

Hi,

I have used the approach but it gives only the max month but i need dynamic month based on the filter selection.

Thanks..

rubenmarin

If the value needs to be calculated in front-end you can use this variable:

=Text(Date(Max(ActivityDate), 'MMM YYYY'))

and you can define the variable in script as:

SET vCurr_Month_Year = "Text(Date(Max(ActivityDate), 'MMM YYYY'))";