# QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

New Contributor III

## Average functions

Hello, I've only just started working with QlikView this week as the company I work for is transitioning to it from Cognos and Excel.

We currently have a customer segmentation model built in Excel which I would like to replicate in QlikView.

Where I'm struggling is calculating average gross sales for our customer base as a whole.

I have a straight table that looks like this:

Location_IDGross SalesGross MarginN. SKUs purchasedAverage SKUs purchased Average gross sales
131.510
2214
310.52
4215

I'm struggling to fill the last two columns with the data I want for subsequent calculations. The last two columns should contain the same number all the way from the top to the bottom. Average SKUs in the example above would be 5.25 and Average gross sales would be 2.

What function should I be using and how should I be scripting it? Is it a variation on Aggr?

Peter

6 Replies
Not applicable

## Re: Average functions

Hi Peter, If you just use Avg(Total [Gross Sales]), that should work.

Not applicable

## Re: Average functions

hi

sum(Total GrossSales)/count(GrossSales)

Not applicable

## Re: Average functions

Hi Peter,

For Average SKUs purchased, you can use : =AVG (TOTAL [N. SKUs purchased]) and for Average gross sales you can use : =AVG(TOTAL [Gross Sales])
Hope this helps!

Valued Contributor

## Re: Average functions

Hi,

I you want below output:

Then you need to add two expressions for calculating average.

1). Avg([N. SKUs purchased])

2). Avg([Gross Sales])

New Contributor III

## Re: Average functions

Thanks for your replies, I've managed to get the right answer for the the Average SKUs for which I used this:

=avg(Total Aggr(count(SKU), location_id)

Rather than have different values against each location I want to have the same value against each. I hope that makes some sort of sense?

New Contributor III

## Re: Average functions

Thanks for your replies, I've managed to get the right answer for the the Average SKUs for which I used this:

=avg(Total Aggr(count(SKU), location_id)

Rather than have different values against each location I want to have the same value against each. I hope that makes some sort of sense?