Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
male_carrasco
Creator
Creator

Median in the script

Hi,

I want to calculate @Median in the script.

I used the following expression in a chart:

Median(TOTAL <LVQ> aggr( sum(HT),IRF_START_TS))

IRF_START_TS = Calls

LVQ= Clasification

HT=Time  in Sec


but i need the median for each LVQ

Do you have any idea?

Regards,

1 Solution

Accepted Solutions
sunny_talwar

Try this script:

Table:

LOAD AgentName,

    HT,

    IRF_START_TS,

    VIP_Bucket

FROM

(biff, embedded labels, table is [Sheet1$]);

Left Join (Table)

LOAD VIP_Bucket,

  Median(Sum_HT) as Median

Group By VIP_Bucket;

LOAD VIP_Bucket,

  IRF_START_TS,

  Sum(HT) as Sum_HT

Resident [Sheet1$]

Group By VIP_Bucket, IRF_START_TS;

View solution in original post

8 Replies
sunny_talwar

Would you be able to provide some sample data with what you are expecting to see as output?

male_carrasco
Creator
Creator
Author

Hi Sunny,

Sorry for the delay.

Please find attached.

sunny_talwar

What is the expected output that you are looking to see from the sample provided?

male_carrasco
Creator
Creator
Author

Hi Sunny!
I need calculate the Median in the script, because the agent could be in different buckets.

The median for Bucket 1 is 672, for Bucket 2 is 233, but if I select agent 1174 the calculate of median change.

I need to know if the agent is close the median or not by bucket... It is the reason why I need the calculation the median in the script...

Thanks for your help!

sunny_talwar

Although I can give you a script based solution, but in the mean time here is a front end based solution:

Median({1}TOTAL <VIP_Bucket> Aggr(Sum({1}HT), IRF_START_TS)) * Avg(1)


Capture.PNG

Any selection made in your application won't impact or change your median number. This is done because of the use of 1 which tells the expression not to change based on any selection made

Median({1}TOTAL <VIP_Bucket> Aggr(Sum({1}HT), IRF_START_TS)) * Avg(1)

Next, I will post a script based solution as well

HTH

Best,

Sunny

male_carrasco
Creator
Creator
Author

Thanks is a possible solution but i have some variables that i did not include in the example, i will waiting the post!

Thanks a lot!

sunny_talwar

Try this script:

Table:

LOAD AgentName,

    HT,

    IRF_START_TS,

    VIP_Bucket

FROM

(biff, embedded labels, table is [Sheet1$]);

Left Join (Table)

LOAD VIP_Bucket,

  Median(Sum_HT) as Median

Group By VIP_Bucket;

LOAD VIP_Bucket,

  IRF_START_TS,

  Sum(HT) as Sum_HT

Resident [Sheet1$]

Group By VIP_Bucket, IRF_START_TS;

male_carrasco
Creator
Creator
Author

Thanks a lot!