Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Moving Range Chart with Enabling Trellis Chart

Hello, I'm trying to create a Moving Range Chart with Enabling Trellis Chart.

If I calculate MRBAR without additional dimension for Trellis Chart, it is working fine.

      where MRBAR = Avg({<Month=>} Total  Aggr(fabs(Above(sum(Data))-sum(Data)), Month))

MonthXXBARMRMRBAR
1406191.1208.3-9.0
1407197.7208.36.69.0
1408203.3208.35.69.0
1409207.0208.33.79.0
1410217.1208.310.19.0
1411218.5208.31.49.0
1412204.9208.313.69.0
1501226.8208.321.9
  • 9.0

But if I add the dimension (country) for Trellis Chart, MRBAR is calculated wrongly like below.

  where MRBAR = Avg({<Month=>} Total <Country> Aggr(fabs(Above(sum(Data))-sum(Data)), Month, Country))

I think MRBAR should be the average of MR in below table, but the result is different from what I expected.

I've attached the qlikview document I've created for this test.

Please, kindly help to check and advise what went wrong.

CountryMonthXXBARMRMRBAR
A140661.862.7--
A140757.562.74.241949023-
A140865.562.77.925399452-
A140956.262.79.230154472-
A141067.362.711.06479128-
A141165.862.71.492584338-
A141261.962.73.897969474-
A150165.962.73.952960342-
B140660.563.2-4.615732832
B140758.563.22.0177396324.615732832
B140852.963.25.559356534.615732832
B140961.063.28.0747663864.615732832
B141064.663.23.5552296984.615732832
B141168.063.23.4718918794.615732832
B141270.563.22.4217476924.615732832
B150169.863.20.6877873894.615732832
C140630.130.5-32.6980821
C140734.130.54.01800825432.6980821
C140832.630.51.53346531532.6980821
C140940.130.57.58702833132.6980821
C141024.530.515.6306959232.6980821
C141129.930.55.38772623732.6980821
C141223.830.56.0969573832.6980821
C150129.130.55.2607523232.6980821
D140638.751.8-21.29796788
D140747.651.88.88981323821.29796788
D140852.351.84.76445295221.29796788
D140949.651.82.73162822121.29796788
D141060.751.811.0786311221.29796788
D141154.751.85.95210723321.29796788
D141248.851.85.98828718521.29796788
D150162.151.813.3939633321.29796788
3 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You need a total in the Above, and you need a condition to handle the change from one country to the next. Perhaps something like:

= Avg({<Month=>} Total <Country>

  Aggr(Fabs(

    If(Country = Above(TOTAL Country),

      Above(TOTAL Sum(Data))-Sum(Data),

     0

    )

, Month, Country))

)

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hello Jonathan,

Thank you for your kind advice.

I've changed the expression for MRBAR like below, but it didn't work.

  • MRBAR = Avg({<Month=>} Total <Country> Aggr(fabs(if(Country = Above(Total Country), Above(Total sum(Data))-sum(Data),0)), Month, Country))

Somehow, all the values are now appeared as '0'.

Could you please kindly check the qvw file I've posted above and help if there is any way to plot the Trellis enabled Control Charts using MRBAR?

CountryMonthXXBARMRMRBAR
A140661.862.7-0
A140757.562.74.2419490230
A140865.562.77.9253994520
A140956.262.79.2301544720
A141067.362.711.064791280
A141165.862.71.4925843380
A141261.962.73.8979694740
A150165.962.73.9529603420
B140660.563.2-0
B140758.563.22.0177396320
B140852.963.25.559356530
B140961.063.28.0747663860
B141064.663.23.5552296980
B141168.063.23.4718918790
B141270.563.22.4217476920
B150169.863.20.6877873890
C140630.130.5-0
C140734.130.54.0180082540
C140832.630.51.5334653150
C140940.130.57.5870283310
C141024.530.515.630695920
C141129.930.55.3877262370
C141223.830.56.096957380
C150129.130.55.260752320
D140638.751.8-0
D140747.651.88.8898132380
D140852.351.84.7644529520
D140949.651.82.7316282210
D141060.751.811.078631120
D141154.751.85.9521072330
D141248.851.85.9882871850
D150162.151.813.393963330
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

These are the correct expressions:

XBAR:  =Avg({< Month=>} TOTAL Aggr(Sum(Data), Country, Month))

MRBAR: =Avg(TOTAL <Country> Aggr(Fabs(Above(Sum(Data)) - Sum(Data)), Country, Month))

This will compute the same XBAR for all countries. Is this what you require? Otherwise XBAR is

XBAR (by country):  =Avg(TOTAL <Country> Aggr(Sum(Data), Country, Month))

Updated chart and table on Sheet1 of the attached.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein