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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
thanhphongle
Creator II
Creator II

is there a scalar product function and a product function in qv?

Hello community,

I have a portfolio with a lot of stocks: I'd like to use the scalar product function to calculate the return:

StockWeightingReturn
Daimler30%17.6%
Siemens20%14,2%
Apple50%19.2%

Expected Return = 30% * 17,6% + 20% * 14,2% + 50% * 19,2% = 17,72%

Does the scalar product function exists?

And the product function

Product(Weighting) = 30%*20%*50%=3%

1 Solution

Accepted Solutions
swuehl
MVP
MVP

=exp(Sum(Log(Weighting)))

View solution in original post

5 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Scalar product: =Sum(Weighting * Return)

There is no simple function for the product of an arbitrary list, I will have to think about how to implement that.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

You could do it iteratively during load for a static version:

LOAD Id,

  WeightFactor,

  WeightFactor * Alt(Peek(ProductWeighting), 1) As ProductWeighting,

  ...

But this will not be suitable if the list to be used for the product is subject to users selections (dynamic version).

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
swuehl
MVP
MVP

=exp(Sum(Log(Weighting)))

thanhphongle
Creator II
Creator II
Author

thought that would be easier to have that scalar function, but as u said i think i have to implement mysself that function

jonathandienst
Partner - Champion III
Partner - Champion III

Brilliant! Why didn't I think of that!

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein