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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
dena_reavis
Employee
Employee

Syntax for one variable divided by another variable...... What am I doing wrong?

I have a variable vSalesUnits which is a total of units.

I have a variable vSalesRevenue which is a total of types of revenues.

Each are working independently but when I try to create a new variable for the Per Unit called vSalesPer_Unit where I divide the total revenue by the units, I can't get it to calculate. 

vSalesPer_Unit is defined like this:

    $(vSalesRevenue ) / $(vSalesUnits )

... doesn't work for me

I've tried putting additional () around each, doesn't work

    ($(vSalesRevenue )) /( $(vSalesUnits ))

I've tried the Div function with and without extra parentheses, didn't work. 

I searched and found a few postings of other people having a similar issue, but I can't find a solution other than extra parentheses.  

Can someone tell what am doing wrong or make a suggestion?

Thank you very much!

Labels (1)
2 Solutions

Accepted Solutions
marcus_sommer

Maybe your variable-result contains a comma as thousand/decimal-delimiter. That's fine by a single-output but it's not a valid number if you want to calculate anything on top of it. In this case you could either adjust the formatting by the variable-creation or you need to consider it by calling the variables, for example with something like:

num(num#($(vSalesRevenue ), '#.##0,00', ',', '.') / num#($(vSalesUnits ), '#.##0,00', ',', '.'), 'YourFormat')

- Marcus

View solution in original post

dena_reavis
Employee
Employee
Author

Thank you Marcus!

While I was trying your suggestion, I noticed a space after one of the variable names before the second parentheses of the dollar sign expansion. I admit I did not think that would cause an issue, but that seems to have been it. I fixed it and now it calculates just fine. 

I had $(vSalesUnits ) instead of $(vSalesUnits)

Thank you both for your quick responses. 

 

 

View solution in original post

3 Replies
othniel2014
Contributor III
Contributor III

Does this work for you?

vDivide =vSalesRevenue/vSalesUnits__.png

marcus_sommer

Maybe your variable-result contains a comma as thousand/decimal-delimiter. That's fine by a single-output but it's not a valid number if you want to calculate anything on top of it. In this case you could either adjust the formatting by the variable-creation or you need to consider it by calling the variables, for example with something like:

num(num#($(vSalesRevenue ), '#.##0,00', ',', '.') / num#($(vSalesUnits ), '#.##0,00', ',', '.'), 'YourFormat')

- Marcus

dena_reavis
Employee
Employee
Author

Thank you Marcus!

While I was trying your suggestion, I noticed a space after one of the variable names before the second parentheses of the dollar sign expansion. I admit I did not think that would cause an issue, but that seems to have been it. I fixed it and now it calculates just fine. 

I had $(vSalesUnits ) instead of $(vSalesUnits)

Thank you both for your quick responses.