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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Rothschild
Contributor II
Contributor II

Median Per Other Column

Hi,

I have a table like this:

unit costquantity
1002
2003
2501
3004
3503

The result of a regular median function on unit cost is 250.

But I want to calculate the median according to quantity:

Median(100,100,200,200,200,250,300,300,300,300,350,350,350) Result: 300.

We do not want to use interval match becouse we have already millions of records.

Does anyone have a solution?

Thanks!

Labels (2)
7 Replies
Chanty4u
MVP
MVP

can you try this

AGGR(MEDIAN([Unit Cost]),Quantity)

Chanty4u
MVP
MVP

or

AGGR(MEDIAN(total <unit cost>Quantity),Quantity)

Rothschild
Contributor II
Contributor II
Author

Does not work.

Chanty4u
MVP
MVP

median(total <Unit cost> Quantity)

Rothschild
Contributor II
Contributor II
Author

Given 1.

marcus_sommer
MVP
MVP

You may try something like this:

=subfield(concat(repeat([unit cost] &',', quantity), ''), ',',
    ceil(substringcount(concat(repeat([unit cost] &',', quantity), ''), ',') / 2))

- Marcus

Rothschild
Contributor II
Contributor II
Author

Hi,

Does Anyone have an idea?

unit costquantity
1002
2003
2501
3004
3503

I have more dimensions.