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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
jlassell
Partner - Contributor II
Partner - Contributor II

Finding MIN of Calculation Across Chart

I am trying to create an expression for the "min cost/day" column below:

productsum(cost)sum(days)cost/daymin cost/day
DILAUDID-52,564.994685.485.48
HYDROMORPHONE HCL131.11168.195.48
OPANA ER233.342111.115.48
OXYCONTIN964.817313.225.48
KADIAN2,752.3819414.195.48


I need to use that value in other calculations for the higher cost/day products -- ie. potential savings if you had used DILAUDID-5 instead of OPANA ER.

I would have thought I could use something like: min( aggr(sum(cost)/sum(days), product) )

but that doesn't seem to work.

Any ideas?

3 Replies
Anonymous
Not applicable

There are probably better ways to go about this but if the table is always sorted with the lowest cost/day on top you can use the following expression to pull the value to the 4th expression:

rangemin(above(Sum(Cost)/Sum(Days),0,Rowno()))

jlassell
Partner - Contributor II
Partner - Contributor II
Author

If I add this expression to the chart I am no longer able to sort the column that has the Cost/Day. Even if I set the Sort Orders the rows don't show up sorted anymore.

jlassell
Partner - Contributor II
Partner - Contributor II
Author

I was able to accomplish what I needed with nested aggr functions.

aggr(nodistinct min( aggr(sum(cost/day), DimX)) , DimY)

Thanks,