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: 
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
swuehl
MVP
MVP

That's probably because salesInc is ambiguous for all classes with a frequency higher than 1.

If you want a sampling point in the center of your class width, try maybe

(floor(salesInc,5)+ceil(salesInc, 5))/2

like

normdist( (floor(salesInc,5)+ceil(salesInc, 5))/2,avg({1} total salesInc),stdev({1} total salesInc),0 )

Not applicable
Author

Thanks for the suggestion but still no luck

These are the figures that the expression is producing

 

 

0.0008

 

0.0051

 

-

 

-

 

-

 

-

 

-

 

-

 

0.0012

 

0.0001

 

0.0000

 

0.0000

 

0.0000

 

-

swuehl
MVP
MVP

Ah, sure, the same problem will persist using just floor() or ceil() function. Hm, maybe:

normdist( (floor(min(salesInc),5)+ceil(min(salesInc), 5))/2,avg({1} total salesInc),stdev({1} total salesInc),0 )

Not applicable
Author

This is the answer I'm getting, it is generating an answer for all the ranges now, however the numbers dont look like how I would expect

 

 

Frequency

 

 

-20 <= x < -15

 

1

 

8.5E-5

 

-15 <= x < -10

 

1

 

0.051645999

 

-10 <= x < -5

 

6

 

0.250697235

 

-5 <= x < 0

 

28

 

0.526009038

 

0 <= x < 5

 

86

 

3.593327034

 

5 <= x < 10

 

29

 

1.211703302

 

10 <= x < 15

 

5

 

0.230117249

 

15 <= x < 20

 

3

 

0.168979575

 

20 <= x < 25

 

1

 

4.1E-16

 

25 <= x < 30

 

1

 

0.006841735

 

30 <= x < 35

 

1

 

9.2E-6

 

40 <= x < 45

 

1

 

1.4E-10

 

45 <= x < 50

 

1

 

1.4E-10

 

-

 

20

 

-

swuehl
MVP
MVP

You are getting numbers larger that 1 using only the normdist() function?

What numbers do you expect?

Not applicable
Author

For a normal distribution curve the numbers should start off small, get bigger(around the mean) and get small again to create a bell curve.

Where as for the first range the number is 8.5, when it should be smaller than the result for the second range.

swuehl
MVP
MVP

Again, I doubt that this is the outcome of just a normdist() function. What is the exact expression you are using?

For the first range, the number is not 8.5, but 8.5E-5, i.e. 0.000085.

Not applicable
Author

Thanks, I over looked that. but I expect the numbers to be higher, a closer value to those in the frequency column.

normdist( (floor(min(salesInc),5)+ceil(min(salesInc), 5))/2,avg({1} total salesInc),stdev({1} total salesInc),0 )

* Count(DISTINCT(SalesId))

for the frequency column I am using -

Count(DISTINCT(SalesId))  

in excel if I was to do this I would perform (normdist-previousNormDist)*totalFrequency and it works.

swuehl
MVP
MVP

I think

Count(DISTINCT(SalesId))

is not the correct factor to norm your bell curve so it does match your numbers.

I think you need to take the total number of SalesId into account:

count(TOTAL DISTINCT SalesId)


Hm, what about your class width? I think you also need to correct for that (so try an additional factor 0.2 (or 5?)

I don't have anymore time today, but maybe you are on the right path already.

manideep78
Partner - Specialist
Partner - Specialist

Hi John Witherspoon

I have the same requirement on the Bell Curve. After a lot of research I could find that your answer is nearer to what I actually need. I did not understood that in the above post why you are multiplying the expression with 600. I did not understood that. Can you please explain me that?

Regards

Manideep