19 Replies Latest reply: Feb 25, 2014 6:26 AM by Manideep Hv RSS

    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,

        • Re: Plotting Normal Dirstribution/ bell curve
          facundo de la cal

          RIGHT CLIC PROPERTIES SORT, Y-VALUES DESCENDING.

          HOPE IT HELPS

          • Re: Plotting Normal Dirstribution/ bell curve
            facundo de la cal

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

            • Re: Plotting Normal Dirstribution/ bell curve
              John Witherspoon

              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.

              • 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))

                  • Re: Plotting Normal Dirstribution/ bell curve
                    John Witherspoon

                    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.

                  • 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?

                      • 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))