Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
rpayn01215
Contributor

Fiscal Master Calendar Script Error ')' Expected

Hi All,

I'm attempting to write a fiscal calendar and need a flag for previous and current year and month, but got stuck. I'm getting errors as commented in the below script. Does anybody have any suggestions or syntax changes to make this logic work?

NoConcatenate

tempFisc2:   //one row table to feed variable values

LOAD

FiscalYear,

FiscalQuarter,

FiscalMonth

Resident tempFiscCal

Where CalendarDate = Date(Now())    //Today's Date >>> should it be Date(Today())?

;

LET v_RP_CFyr = peek('FiscalYear', 0, 'tempFisc2');      //should have a value of '2016', 1st (only) row of above

LET v_RP_CFQ = peek('FiscalQuarter', 0, 'tempFisc2');

LET v_RP_CFMo = peek('FiscalMonth', 0, 'tempFisc2');

NoConcatenate

FiscCal:

LOAD *,

FiscalMonth & '-' & FiscalYear as FiscalMonthYear,

if($(v_RP_CFyr) = FiscalYear, 1,0) as cFYr_Flag,      //says ')' expected

if(peek('FiscalYear', 0, 'tempFisc2') = FiscalYear, 1, 0) as cFYr_Flag2     //tried this, returns 0 only

if(v_RP_CFyr = FiscalYear, 1,0) as cFYr_Flag3,      //field not found (due to resident load)

Resident tempFiscCal;

DROP Table tempFiscCal, tempFisc2;

1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: Fiscal Master Calendar Script Error ')' Expected

I think the reason is how you used the variables - if a variable contained a numeric value you could access them with $(var) and if they contained a string you need single-quotes around the variable like: '$(var)'

Here you find many useful links to fiscal calendar and flagging from periods and some more topics: How to use - Master-Calendar and Date-Values.

- Marcus

View solution in original post

3 Replies
israelcsouza
New Contributor III

Re: Fiscal Master Calendar Script Error ')' Expected

Hi Ron Payne,

Upload the QVW exemple.

MVP & Luminary
MVP & Luminary

Re: Fiscal Master Calendar Script Error ')' Expected

I think the reason is how you used the variables - if a variable contained a numeric value you could access them with $(var) and if they contained a string you need single-quotes around the variable like: '$(var)'

Here you find many useful links to fiscal calendar and flagging from periods and some more topics: How to use - Master-Calendar and Date-Values.

- Marcus

View solution in original post

rpayn01215
Contributor

Re: Fiscal Master Calendar Script Error ')' Expected

Thanks, Marc. This was a good suggestion. I have forced my variable to num and changed WHERE... date(now()) to date(today()). I'm uploading the same qvw to show you how it works using the variables before the final load.