Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
bohravanraj
Partner - Creator II
Partner - Creator II

Creation of Dyanamic Bucket

Hello Guys,

I want to create a dynamic bucket on For Quantity field.

Bucket Should be 0-10,10-100,100-1000,1000-10000,.....

thanx.

1 Solution

Accepted Solutions
MarcoWedel

Hi,

one solution could be also:

QlikCommunity_Thread_146562_Pic1.JPG

t1:

LOAD *,

    If(no>=0 and no<10,

        Dual('0 - 10',1),

        If(no>-10 and no<0,

          Dual('-10 - 0', -1),

          If(no>=10,

              Dual(pow(10,Class(log10(no),1))&' - '&pow(10,Class(log10(no),1)+1), pow(10,Class(log10(no),1))),

              If(no<=-10,

                Dual('-'&pow(10,Class(log10(-no),1)+1)&' - -'&pow(10,Class(log10(-no),1)), -pow(10,Class(log10(-no),1)))

                )

            )

          )  

      ) as buck

INLINE [

    no

    0.5

    0.9

    1

    10

    23

    43

    54

    100

    200

    500

    1000

    2000

    5000

    10000

    20000

    99

    0

    -11

    -0.5

    -0.9

    -1

    -10

    -23

    -43

    -54

    -100

    -200

    -500

    -1000

    -2000

    -5000

    -10000

    -20000

    -99

];

hope this helps

regards

Marco

View solution in original post

10 Replies
Gysbert_Wassenaar

Create a calculated dimension: =class(log10(Field))


talk is cheap, supply exceeds demand
Anonymous
Not applicable

len ( round ( [Quantity] ) )    as [Number of digits bucket] ,

bohravanraj
Partner - Creator II
Partner - Creator II
Author

hi Gysbert,

can we create this bucket at a backend using this logic because it is showing error.

Gysbert_Wassenaar

Probably

Load MyValue, class(log10(MyValue)), ...other fields.... as class

From ...somewhere...;


talk is cheap, supply exceeds demand
bohravanraj
Partner - Creator II
Partner - Creator II
Author

t1:

LOAD * INLINE [

    no

    23

    43

    54

    1000

    99

    -11

];

t2:

LOAD no,Class(log(no)) as buck

Resident t1;

DROP Table t1;

it is giving error for this code at a script level

Gysbert_Wassenaar

Bucket Should be 0-10,10-100,100-1000,1000-10000,.....

So.... in which bucket should a value like -11 fall then?


talk is cheap, supply exceeds demand
bohravanraj
Partner - Creator II
Partner - Creator II
Author

it should be in 0 to - 10,

Bucket should also be for negative for example

....,-1000 to -100,-100 to -10, -10 to 0,  0-10,10-100,100-1000,1000-10000,....

Gysbert_Wassenaar

Maybe this:

Load MyValue,

     if(MyValue>=0, class(log10(MyValue)),class(-log10(-MyValue))), ...other fields.... as class

From ...somewhere...;


talk is cheap, supply exceeds demand
MarcoWedel

Hi,

one solution could be also:

QlikCommunity_Thread_146562_Pic1.JPG

t1:

LOAD *,

    If(no>=0 and no<10,

        Dual('0 - 10',1),

        If(no>-10 and no<0,

          Dual('-10 - 0', -1),

          If(no>=10,

              Dual(pow(10,Class(log10(no),1))&' - '&pow(10,Class(log10(no),1)+1), pow(10,Class(log10(no),1))),

              If(no<=-10,

                Dual('-'&pow(10,Class(log10(-no),1)+1)&' - -'&pow(10,Class(log10(-no),1)), -pow(10,Class(log10(-no),1)))

                )

            )

          )  

      ) as buck

INLINE [

    no

    0.5

    0.9

    1

    10

    23

    43

    54

    100

    200

    500

    1000

    2000

    5000

    10000

    20000

    99

    0

    -11

    -0.5

    -0.9

    -1

    -10

    -23

    -43

    -54

    -100

    -200

    -500

    -1000

    -2000

    -5000

    -10000

    -20000

    -99

];

hope this helps

regards

Marco