Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join this live chat April 6, 10AM EST - QlikView to Qlik Sense REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Divide two variables in an expression

Hello,

Can anyone help me with the following:

In the script, I have declared two variables for a dashboard view:

let vSalesCY='Sum ({1<Sales_Cust_Class_Code-={100},D_Date.Cal_Yr={$(vFY_0)}>}Restate_USD_Net_Sales_Amt_Ext)/1000';
let vSalesLY='Sum ({1<Sales_Cust_Class_Code-={100},D_Date.Cal_Yr={$(vFY_1)}>}Restate_USD_Net_Sales_Amt_Ext)/1000';

I use them in a chart (table) which works fine as =$(vSalesCY)

I want to add the difference in a 3rd column by dividing the two:

=S(vSalesCY) / S(vSalesLY

(I can add, substract, multiply the two variables, but not divide...

It gives me an incorrect result; can I not so something like this?

(I did also try =$((S(vSalesCY) / S(vSalesLY))


Thanks Hans

1 Solution

Accepted Solutions
Not applicable
Author

Yes!

it works fine, Oleg

Thank you very much.

Rgds

Hans

View solution in original post

2 Replies
Oleg_Troyansky

The problem is caused by the division that happens within the calculations stored in variables. When the two formulas are divided by each other, the division signs get mixed up.

The easiest and the most universal solution is to enclose your initial formulas within the variables in another pair of parentheses:

let vSalesCY='(Sum ({1<Sales_Cust_Class_Code-={100},D_Date.Cal_Yr={$(vFY_0)}>}Restate_USD_Net_Sales_Amt_Ext)/1000)';

this way, the formula will always work, no matter what other operations are used on top.

cheers,

Oleg Troyansky

QlikView Your Business: An expert guide to Business Discovery with QlikView and Qlik Sense

Not applicable
Author

Yes!

it works fine, Oleg

Thank you very much.

Rgds

Hans

View solution in original post