Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Divide dimension by Variable in a script

Hi all,

This question is a continuation of a previous thread: Re: Variable in Script - Assign Value based on If Statement

I have a variable v12WeekAverageCalc that has been defined as follows: (Thanks to Vish's help  )

= Pick(vReportCurrent_Period, 24, 24, 24, 15, 15, 15, 18, 18, 18, 21, 21, 21)

This picks up the current financial period (defined in vReportCurrent_Period) from my database and assigns a predefined numerical value based on the current financial period.

Period 1,2,3 = 24

Period 4,5,6 = 15

Period 7,8,9 = 18

Period 10,11,12 = 21

I need to use these numerical values to calculate average QTY sales based on a number of months...

variable settings.JPG

vReportCurrent_Period is defined as follows in another part of my script:

Period:

LOAD "fin_year" as FinancialYear,

"Period" as FinancialPeriod;

SQL SELECT "fin_year", "Period"

FROM PUB.perlive

where Module ='iv';

LET vReportCurrent_FinYear = FieldValue('FinancialYear',1);

LET vReportCurrent_Period =  FieldValue('FinancialPeriod',1);

DROP TABLE Period;

Both v12WeekAverageCalc and vReportCurrent_Period are giving the correct output.



Now I need to use v12WeekAverageCalc in a calculation as follows.


QTYSalesValueX / v12WeekAverageCalc = 12WeekAvgQTYSales

here's my actual script for that section:

ISHRB12WeekAverageQtySales:

Load

ISHRBSKU,

(ISHRB12WeekAvgQTYSales_temp / $(v12WeekAverageCalc)) as ISHRB12WeekAvgQTYSales

Resident ISHRB12WeekAverageQtySales_temp;

I need to display ISHRB12WeekAvgQTYSales in my pivot chart.


I am getting this error:


variable script error.jpg

Can anyone help??

Thanks in advance...

Cheers,

Fab

10 Replies
Anonymous
Not applicable
Author

Thanks again Vish,

would have never got it to work without your input...

Much appreciated...

Cheers,

Fab