# New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
New Contributor III

## SPC Highlights

HI,

I have been trying to follow a very useful post from Erica Whalley at

QlikFit: Qlikview Lean tips #1: How to highlight series of points that violate control rules on a ch...

I have run into a problem though.

this expressions requires an average, which I want to be dynamic.

=if(RowNo()=1 or count(Key)>([Average]),0,above(R2CUM)+(count(Key)<=(Average]))

I have tried using the average expression

avg(aggr(Count(Key),Week))

but of course this just returns the count(Key) because it is averaging and aggregating it over the one week in the chart.

the only way around this I can find is to calculate the average manually as below

=if(RowNo()=1 or count(Key)>(count(total Key)/NoOfRows()),0,above(R2CUM)+(count(Key)<=(count(total Key)/NoOfRows())))

which is fine for highlighting points above/below the mean but I also want to highlight above or below the UCL and LCL.

so is there a way around this problem please?

thanks once again for your time.

Kind Regards

Steve

Tags (6)
1 Solution

Accepted Solutions
MVP

## Re: SPC Highlights

You can calculate average like this

Avg(TOTAL Aggr(Count(Key), Week))

and stdev like this

Stdev(TOTAL Aggr(Count(Key), Week))

11 Replies
Honored Contributor III

Hi Steven,

Thanks

MVP

## Re: SPC Highlights

Would you be able to share a sample where we can see the issue?

New Contributor III

## Re: SPC Highlights

hi Sunny, sorry it has taken a while to respond - I have been off.

I can't see how to share the document?

Steve

MVP

## Re: SPC Highlights

New Contributor III

## Re: SPC Highlights

Thanks Sunny - I was trying to reply through the inbox - hence the problem!

The formula in question is R2CUM. it works for highlighting points above and below the average but  I have had to manually calculate the average as you will see in the expression. The problem is I want to do the same thing for over the UCL or under the LCL - which I can't do from a manual expression -hence I have a problem...

Kind Regards

Steve

MVP

## Re: SPC Highlights

Would you be able to expand what do you mean by manual expression?

New Contributor III

## Re: SPC Highlights

The average is being calculated from

count(total Key)/NoOfRows()

rather than by using an expression from avg()

this means I cannot use stdev() to adapt the expression to highlight above and below UCL or LCL.

MVP

## Re: SPC Highlights

You can calculate average like this

Avg(TOTAL Aggr(Count(Key), Week))

and stdev like this

Stdev(TOTAL Aggr(Count(Key), Week))

New Contributor III

## Re: SPC Highlights

ahhh... is it the TOTAL that makes a difference? I tried it without the TOTAL and it returned count(Key)?

Brilliant - really appreciate your help - thank you.