Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
AWS Degraded - You may experience Community slowness, timeouts, or trouble accessing: LATEST HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
schumi1980
Contributor III
Contributor III

Median of several expressions

Hi All

I calculated the loss ratio per month for the accident years

   

MonthAY 2010AY 2011AY 2012AY 2013AY 2014AY 2015
150%60%77%66%74%58%
260%90%88%67%66%59%
340%90%90%68%85%60%
460%95%105%90%90%40%
570%100%99%80%100%60%

AY 2010 to AY 2015 are expressions.

I would now like to calculate the median of the expression values.

I tried

Median([AY 2010],[AY 2011],[AY 2012],[AY 2013],[AY 2014],[AY 2015])

But that does not work. How could I calculate the median of the 6 expressions?

Many thanks.

Best regards,

Jan

4 Replies
avkeep01
Partner - Specialist
Partner - Specialist

Hi Jan,

Try using CROSSTABLE in front of your load statement in the script:

CROSSTABLE LOAD * INLINE [

Month, AY 2010, AY 2011, AY 2012, AY 2013, AY 2014, AY 2015

1, 50%, 60%, 77%, 66%, 74%, 58%

2, 60%, 90%, 88%, 67%, 66%, 59%

3, 40%, 90%, 90%, 68%, 85%, 60%

4, 60%, 95%, 105%, 90%, 90%, 40%

5, 70%, 100%, 99%, 80%, 100%, 60%

];

avkeep01
Partner - Specialist
Partner - Specialist

Hi Jan,

This function also gives results:

MEDIAN(AGGR([AY 2010],[AY 2011],[AY 2012],[AY 2013],[AY 2014],[AY 2015]))

this result = 0.6 while the result from my previous answer is 0.72. Not sure which one is correct.

marcus_sommer

You could use rangefractile() for it like described in the help:

rangefractile(quantil ,formel1 [ , formel2, ... formelN ])

Liefert das Quantil der numerischen Werte innerhalb der Argumente 1 bis N.

Die Menge der Argumente dieser Funktion kann durch „Inter-Record-Funktionen“ (siehe Inter-Record-Funktionen im Diagramm) berechnet werden, mit einem dritten optionalen Parameter, der auch wieder eine Anzahl Werte liefert.

Beispiele:

   

rangefractile (0.24,1,2,4,6)liefert 1
rangefractile (0.5,1,2,3,4,6)liefert 3
rangefractile (0.5,1,2,5,6)liefert 3,5
rangefractile (0.5, above(sum(x),-1,3))liefert den Median der drei Ergebnisse der sum(x)-Funktion, berechnet anhand der Werte der Zeile nach der aktuellen Zeile, der aktuellen Zeile und der Zeile vor der aktuellen Zeile.

- Marcus

MarcoWedel

Hi,

two examples of possible solutions, using the already proposed crosstable and Median(Aggr()) functions as well as a conditional selection of expressions based on the Secondarydimensionality() in a pivot table:

QlikCommunity_Thread_283240_Pic1.JPG

QlikCommunity_Thread_283240_Pic2.JPG

QlikCommunity_Thread_283240_Pic3.JPG

QlikCommunity_Thread_283240_Pic4.JPG

QlikCommunity_Thread_283240_Pic5.JPG

QlikCommunity_Thread_283240_Pic6.JPG

QlikCommunity_Thread_283240_Pic7.JPG

table1:

CrossTable (Year,Value)

LOAD * FROM [https://community.qlik.com/thread/283240] (html, codepage is 1252, embedded labels, table is @1);

hope this helps

regards

Marco