Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Median value on x-axis

I have a bar chart (histogram, really) where the x-axis is a rounded number of hours (the delay in hours between admission to hospital and the start of surgery), and the y-axis is the number of cases.

Is there a way to show a vertical line at the median number of hours?

RoundedOpDelay is a dimension, calculated on data load.  However, I also have a separate numeric field called Delay(Hrs) to two decimal places if that works better.

Thanks,

Steve

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Hadn't noticed that there is no X/Y option for the ref line (unlike that other product). What a disappointment.

You could color the bar closest to the median as a sort of workaround.

-Rob

View solution in original post

12 Replies
zhadrakas
Specialist II
Specialist II

you can try this Expression

median(TOTAL [Delay(Hrs)])

Anonymous
Not applicable
Author

Thanks, Tim,

I have a KPI box that shows the median value as a number using your formula, and maybe I should be satisfied with that.  It would be really impressive, though, to have a different-coloured vertical line on the chart.

To chart this as a second dimension I would need something to use as a Y-axis number, probably matching the maximum number of operations per RoundedOpDelay (or the chart range).

Any suggestions?

Thanks again,

Steve

zhadrakas
Specialist II
Specialist II

what about adding this expression median(TOTAL [Delay(Hrs)]and display as line

the screenshot is only an example

regards

tim

Anonymous
Not applicable
Author

Thanks, Tim,

If you were to group your Total Sales into, say, $500 blocks and chart them on the X-axis, you would be able to chart the number of times you hit each group of $500.  Looking at your example, there would be a value of 1 for <$500, 6 for $1000, 3 for $1500, 4 for $2000, 0 for $2500, 2 for $3000, 0 for $3500 and 1 for $4000.  (Be patient here; I'm sitting with a ruler pressed on the screen and people are laughing at me.)

Your data doesn't readily lend itself to my histogram, but this is the sort of thing I'm hoping for:

The columns represent the $500 groups; the value is a count of order dates, and the vertical red line represents the median order value.

On my bar chart at the top, the vertical red line would probably turn up at about 17 hours, as there's a long tail out to the right.

Thanks for your interest!

Steve

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The Reference Line option for Bar Chart should be available under Add-ons, Reference Lines.

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

Anonymous
Not applicable
Author

Thanks Rob,

I can add the median value as a reference line, but it plots against the Y-axis as a horizontal line, rather than on the x axis, vertically.

Thanks for your help!

Steve

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Hadn't noticed that there is no X/Y option for the ref line (unlike that other product). What a disappointment.

You could color the bar closest to the median as a sort of workaround.

-Rob

Anonymous
Not applicable
Author

Hi,

In case anybody is looking for this answer - seems unlikely - here's what I did:

I used color by expression, using this:

I had hoped to find the RGB value for the standard colors but in the end I used a color picker and found the closest I could.

Thanks for the suggestion, Rob.

Steve

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

To use a color from the standard palette, you can use the color(n) function. e.g. "color(2)" for the red color. These are slightly less saturated versions than the auto colors, but at least you get consistency.

-Rob

http://masterssummit.com

http://qlikviewcookbook.com