Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using 'only' within a formula

Hi there,


Completely novice to Qlikview so apologies for a simple question....


I was originally using:


sum({<RetailYear = {'2013'}>}Quantity)*TradePrice


Which I then worked out will multiply the sum of the trade price by the sum of the quantity for the retail year 2013 which is not correct.


So I need to add 'only' into the formula so that it multiplies the trade price only, not the sum of the trade price. I've tried the below as it seems to make the most logical sense but it doesn't work (has an 'error in expression'). Where should the 'only' be?

sum({<RetailYear = {'2013'}>}Quantity)*only(TradePrice)

TIA

Sarah

4 Replies
Colin-Albert

Try this

sum({<RetailYear = {'2013'}>} Quantity * TradePrice)


Only returns a single value if the selected field has a single value otherwise it returns null.

Anonymous
Not applicable
Author

Alternatively you can in the script do

Quantity * TradePrice as [# Amount]

Then in the document

sum({<RetailYear = {'2013'}>} [# Amount])

Anonymous
Not applicable
Author

Better you do this calculation in script only.

or use max/min instead of only in expression if you are having single tradeprice of every item in price master..

Not applicable
Author

Hi,

You Can create value like,

As per Michael Answer,

Let vAmt = Num(Quantity * TradePrice,'<Format >');

Then,

Sum ({RetailYear = { '2013'}>} $(vAmt)}

Regards,

Raja.