Qlik Community

QlikView Documents

Documents for QlikView related information.

Average Calculation

Elkhan
New Contributor

Average Calculation

Hi, 

 

I am a beginner user in Qlik. Recently the developer made a table where I have a number of items and net sales sold in every country. 

Now I would like to calculate the average item price in the same table by using an expression: 

 Sum({<[Flag.Current]={1}>}[#NetSales]/[#SalesQuantity]) 

I basically took NetSales expression and tried to divide it in Sales Quantity, this is what I would do in a calculator, but it, of course, does not work in QS.

Could you please help me?  

 

Thank you in advance. 

Comments
Partner
Partner

Hi,

The expression summarizes the unit prices into one value, not counting the average unit price. The question is what average do you want to calculate, try the following:

1) For the weighted average, try the following expression (recommended)

Sum({<[Flag.Current]={1}>}[#NetSales]) /Sum({<[Flag.Current]={1}>}[#SalesQuantity]) 


2) For the average absolute value of unit prices, ask the developer to create a new field in the data model in which the unit price per line is calculated in the script and then just use the AVG function in the table AVG(DISTINCT #UnitPrice).

RudyK

0 Likes
Version history
Revision #:
1 of 1
Last update:
a month ago
Updated by:
 
Contributors