Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Not applicable

Plotting Normal Dirstribution/ bell curve

Hi

I am trying to plot a Normal Distribution curve over the following barchart of sales increase.

Sales increase is a decimal representing the % increase.

I have tried a number of expressions but I'm having no luck,

I've tried using the NORMDIST function which I've played around but it isnt working, as well as creating an expression from scratch.

normdist(salesInc,avg(salesInc),stdev(salesInc))

normaldistExample.png

for the graph I use the

dimension class(salesInc,5)

expression count(salesInc)

I'd be greatfull if you could point me in the right direction or show me some qlikview examples of normaldistribution,

19 Replies
fdelacal
Valued Contributor

Re: Plotting Normal Dirstribution/ bell curve

RIGHT CLIC PROPERTIES SORT, Y-VALUES DESCENDING.

HOPE IT HELPS

Not applicable

Re: Plotting Normal Dirstribution/ bell curve

Thanks Facundo,

I think the problem is more to do with my expressions for the normal distribution curve,as the Y axis and bar graph is how I would like it.

fdelacal
Valued Contributor

Re: Plotting Normal Dirstribution/ bell curve

can you add a qwv.?? to see real what happend?

MVP
MVP

Re: Plotting Normal Dirstribution/ bell curve

The normdist() function is cumulative, so I think you'll need to do something like this:

normdist(salesInc,avg(salesInc),stdev(salesInc))
-normdist(above(salesInc),avg(salesInc),stdev(salesInc))

I probably have something wrong there, but it's hard to know without a QVW to play with.

Not applicable

Re: Plotting Normal Dirstribution/ bell curve

Thanks John

I've played around with it and so far this formula seems to be producing a line on my graph i just need to see if its the right line.

I think my problem was with the class(salesInc, 10) function,I moved it from being a calculated dimension to being part of the expresssion

normdistCLASS(salesInc, 10) ,avg({1} total CLASS(salesInc, 10)),stdev({1} total CLASS(salesInc, 10)))
-normdist(above(CLASS(salesIncc, 10)),avg({1} total CLASS(salesInc, 10)),stdev({1} total CLASS(salesInc, 10)))) / (CLASS(salesInc,10)-above(CLASS(salesInc, 10))

MVP
MVP

Re: Plotting Normal Dirstribution/ bell curve

I found an example on my hard drive of calculating a normal distribution curve from points. 

600*(normdist(      AHT ,avg({1} total AHT),stdev({1} total AHT))
    -normdist(above(AHT),avg({1} total AHT),stdev({1} total AHT)))
   /(AHT-above(AHT))

On brief glance, it looks like what you're doing other than the 600 part and your use of class().  So I suspect you have it working right.  As a possible simplification, rather than use class() in the expression or dimension, you could create a salesIncClass field in the script.

MVP
MVP

Re: Plotting Normal Dirstribution/ bell curve

There is in fact a fourth argument you can use with the normdist() function (it's not in the HELP, but in the editor tooltip), where you can switch between cumulative and non cumulative mode, so

normdistCLASS(salesInc, 10) ,avg({1} total CLASS(salesInc, 10)),stdev({1} totalCLASS(salesInc, 10)),0 )

should be enough.

Not applicable

Re: Plotting Normal Dirstribution/ bell curve

Hi,

I the formula above works to show the curve but does not work when the variables are grouped together, I have tried to group them together in the load script but it doesnt work as the x axis needs to be a number.

At the moment the x-axis is continuous numbers so the bars are counded for each individual number rather than a group.

Can anyone help me group the x axis?

Not applicable

Re: Plotting Normal Dirstribution/ bell curve

when I view my chart in table format these are the values that I have for some reason there is an error calculating the values around he mean

FrequencyNormal FrequencyNormal Frequency
-20 <= x < -1510.000338372-
-15 <= x < -1010.0093220850.028161867
-10 <= x < -56--
-5 <= x < 028--
0 <= x < 586--
5 <= x < 1029--
10 <= x < 155--
15 <= x < 203--
20 <= x < 2510.002968246-
25 <= x < 3010.0002277470.007159788
30 <= x < 3511.6E-50.000422699
40 <= x < 4511.5E-92.7E-5
45 <= x < 5011.4E-101.6E-9
-20--

The first Column is the dimension  - class(salesInc,5)

2nd colomn expression - expression count(distinct salesId)

3rd column -normdist( salesInc,avg({1} total salesInc),stdev({1} total salesInc),0 )

4th comumn -   (normdist( salesInc ,avg({1} total salesInc),stdev({1} total salesInc))
-
normdist(above(salesInc),avg({1} total salesInc),stdev({1} total salesInc)))

* Count(DISTINCT

salesId))
Community Browser