Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Aggregating a result based on a median function

Hello,

I have a data set similar to below, but with far more data points:

FACNUMSURVEYResultMonthQuarterFiscal Year
00000123477JanQ1FY13
00000123472FebQ1FY13
00000123473MarQ1FY13
00000123474AprQ2FY13
00000123475MayQ2FY13
00000123476JunQ2FY13
00000134565JanQ1FY13
00000134569FebQ1FY13
00000134568MarQ1FY13
00000134570AprQ2FY13
00000134576MayQ2FY13
00000134567JunQ2FY13

FACNUM is a unique key representing a single facility, SURVEYResult is the raw data, and the rest should be self explanatory.  Currently within my dashboard Month, Quarter, and Fiscal year are grouped into a cycle group called Year.  What I would like to do is aggregate the results that come from the below logic:

Based on the position of the cycle group, take the median of the data set, then apply the following if-then logic:

If (Median(SURVEYResult)>= 77, 'Top Quartile', if(Median(SURVEYResult)<77 and Median(SURVEYResult)>=73, 'Abv Average', if(Median(SURVEYResult)<73, 'Below Average')))

The groupings are based on relative comparisons to an outside national benchmark.  Ultimately, with this flag I want to count how many groups exist given the cycle group that is currently selected:

Count(Result of logic)

For example, if the cycle group was on fiscal year, then the result would return 1 facility that is Abv Average and 1 facility that is Below Average with scores of 74.5 and 68.5 respectively.  If the cycle group ended on Quarter, then for Q1 and Q2 the results would be the same, but the raw values would be different:

Q1 - 1 facility Abv Average, 1 facility Below Average with scores of 73 and 68 respectively

Q2 - 1 facility Abv Average, 1 facility Below Average with scores of 68 and 70 respectively

Ultimately I want to approach it as dynamically as possible because this should work when an end user selects a custom grouping of months from a provided list. The Quarters and Fiscal Year grouping is being used as a default group when a user doesn't select any months.

I hope this made some degree of sense.  I've tried employing the aggr() function but I think I might be goofing that up, as well. Any help is appreciated.

0 Replies