Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE

Average Calculation

cancel
Showing results for 
Search instead for 
Did you mean: 
Elkhan
Contributor
Contributor

Average Calculation

Last Update:

Sep 21, 2022 1:07:35 PM

Updated By:

Sue_Macaluso

Created date:

Aug 23, 2019 5:24:18 AM

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. 

Tags (1)
Comments
RudyK
Partner - Contributor II
Partner - Contributor II

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

Contributors
Version history
Last update:
‎2022-09-21 01:07 PM
Updated by: