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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
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

But it is giving the text only.

sunny_talwar

This came back to SET instead of LET, but nareshthavidishetty‌ mentioned SET won't work here.

Not sure why it won't work

rubenmarin

Your original post shows a text box with 'Oct 2016' and you original expression is a concatenation of strings wich will return also a text, what you want if it's not a text?

nareshthavidishetty
Creator III
Creator III
Author

Hi,

I have used the set but it gives the text only.

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

Result : "Text(Date(Max(ActivityDate), 'MMM YYYY'))"

Thanks..

rubenmarin

Ok, now I understand, add an starting equal sign:

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

sunny_talwar

May be you need to add an equal sign?

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

nareshthavidishetty
Creator III
Creator III
Author

Hi,

Please find the below

let vCurr_Month_Year = month(monthstart(($(vMaxCal))-1))&' '&(year($(vMaxCal))) ;

let vLast_Month_Year =  month(monthstart(($(vMaxCal))-1))&' '&(year($(vMaxCal))-1);

let vmonth =MonthName($(vMaxCal));

Let CurrentYear=year(today()-1);

Let LastYear=year(addyears(today()-1,-1));

Let CurrentMonth=month(today()-1);

Let LastMonth=month(addyears(today()-1,-1));

LOAD * INLINE [

    KPI, SortOrder

  $(vCurr_Month_Year), 1

    $(vLast_Month_Year), 2

    DELTA by MARKET, 3

    DELTA by SSS, 4

   ];

LOAD * INLINE [

    KPI, KPI2, SORTORDER2

    $(vCurr_Month_Year), TRAFFIC, 1

    $(vCurr_Month_Year), CUSTPAYS, 2

    $(vCurr_Month_Year), INVCOUNT, 3

    $(vCurr_Month_Year), ADJ TRAFFIC, 4

    $(vCurr_Month_Year), CLOSERATE, 5

    $(vCurr_Month_Year), WRITTENAMT, 6

    $(vCurr_Month_Year), AVGINVOICE, 7

];

Front end:

Untitled.png

Expression logic:

if(KPI= '$(vCurr_Month_Year)' and KPI2='TRAFFIC', num(Sum({<Year={'$(vCurrentYear)'}>}TRAFFIC),'#,##0'),

if(KPI= vCurr_Month_Year and KPI2= 'CUSTPAYS', Sum({<Year={'$(vCurrentYear)'} >}CUSTPAYS),

if(KPI= vCurr_Month_Year and KPI2='INVCOUNT', Sum({<Year={'$(vCurrentYear)'} >}INVCOUNT),

if(KPI= vCurr_Month_Year and KPI2='ADJ TRAFFIC' , num(Sum({<Year={'$(vCurrentYear)'} >}ESTCUST),'#,##0'),

if(KPI='DELTA by MARKET'and KPI2='ADJ TRAFFIC', num(((Sum({<Year={'$(vCurrentYear)'} >}ESTCUST)-Sum({<Year={'$(vLastYear)'} >}ESTCUST))/Sum({<Year={'$(vLastYear)'} >}ESTCUST)),'#.#%')

In the above chart label i need to month and year label as dynamic.

Thanks..

nareshthavidishetty
Creator III
Creator III
Author

Hi,

The above is the script and expression logic.Please let me know what to done to get dynamic month lable.

Thanks..

tresesco
MVP
MVP

Could you post your qvw sample ?

Anil_Babu_Samineni

Try from Label Like below

Current Month

------------------------

='Month' & Max(Month)

Previous Month

-----------------------

='Month' & Max(Month)-1

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