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: 
Not applicable

Expressions with variables

Hi, I am new with QlikView and have a problem using variables:

I have defined the following variables:

v1:

sum({$<[Type]={'Apples'}>} [Total value])+

sum({$<[Type]={'Oranges'}>} [Total value])

v2:

COUNT(DISTINCT {$<[Invoice]={'Main'}>}InvoiceMonth)

I have uploaded the 3 different invoices with the values of the Apples and Oranges

v1: Gives me the total cost of Apples and Oranges.

v2: Gives me the number of invoices I have loaded.

I need to get the average cost and then extrapolate it for the whole year. I have defined the valariables as I have diferent types of invoices and that have been uploaded in different periods.

When I include in a table the following expressoins:

Ex1 =$(v1)  and I get the correct sum: 992.19

Ex2 =$(v2) and I get the correct number of invoices: 3

Then in a new expression I add:

=($(v1)/$(v2))*12

And the result is 5424.44 which is incorrect as (992.19/3)*12 = 3968.76

If I use the names of the expressions Ex1 and Ex2 it works fine, but I want to use the variables as the expressions are only there for testing!

Can someone help me with this?

Thanks a lot!

1 Solution

Accepted Solutions
MayilVahanan

Hi

Try like this

v3 = $(v1)/$(v2)

Ex3 =$(v3)*12

Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

3 Replies
tresesco
MVP
MVP

try with Column() function, like:

(Column(1)/Column(2))*12

Or, in your case

(Ex1/Ex2)*12

MayilVahanan

Hi

Try like this

v3 = $(v1)/$(v2)

Ex3 =$(v3)*12

Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Thanks, This worked fine, but still can not understand why a new variable is needed!

Thanks again