# Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

New Contributor II

## Incorrect average total in pivot table

Hi,

I use the following measure to calculate my percentages per Year/Month:
Count(distinct [PurchDoc])/count(total< [Year/Month] >distinct [PurchDoc])

I expected the pivot table to calculate the average of the percentages for each column in the totals. Yet when I compare the totals from Qlik Sense with the average I calculated in Excel there is a difference for one column (53% instead of 56%).

Why is this?

1 Solution

Accepted Solutions

## Re: Incorrect average total in pivot table

Hi,

The expression works well.

Here is the QVF.

Also the Screenshot.

Regards,

Kaushik Solanki

8 Replies
MVP

## Re: Incorrect average total in pivot table

Can you try this:

Avg(Aggr(Count(distinct [PurchDoc])/count(total< [Year/Month] >distinct [PurchDoc]), [Year/Month], [Buying Channel]))

## Re: Incorrect average total in pivot table

Hi,

Try this expression,

Avg(Aggr(Count(distinct [PurchDoc])/count(total< [Year/Month] >distinct [PurchDoc]),[Buying Channel]))

Regards,

Kaushik Solanki

New Contributor II

## Re: Incorrect average total in pivot table

I tried both expressions but it still displays an incorrect average of 53%.

MVP

## Re: Incorrect average total in pivot table

Would you be able to share a sample?

New Contributor II

## Re: Incorrect average total in pivot table

No problem. See attachment.

## Re: Incorrect average total in pivot table

Hi,

The expression works well.

Here is the QVF.

Also the Screenshot.

Regards,

Kaushik Solanki

MVP

## Re: Incorrect average total in pivot table

Precisely, I think you might have just checked one expression and forgot to check mine. This one does seem to work:

Avg(Aggr(Count(distinct [PurchDoc])/count(total< [Year/Month] >distinct [PurchDoc]), [Year/Month], [Buying Channel]))

New Contributor II

## Re: Incorrect average total in pivot table

You're right. The expression works well. I was just implementing it in the wrong area. I thought it was to be inserted in the totals.