Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
jim_chan
Specialist
Specialist

bar chart with price range list box

i have created a bar chart with price.  i want to create a listbox price range as a filter. Can anyone out there help help??

I need to have a price range

<1000

1001 - 2000

2001-3000

3001-5000

>5000

how can i do that? should i do it in back end script?

Rgds

Jim

8 Replies
tamilarasu
Champion
Champion

You can create the field in backend.

If (FieldName <1000,'<1000',

  if(FieldName <= 2000,'1001 - 2000',

     if(FieldName <= 3000 ,'2001-3000',

            if(FieldName <= 5000,'3001-5000', '>5000')))) as [Price Range],

jim_chan
Specialist
Specialist
Author

Tamil, there are errors when i added in your if statement.

jim_chan
Specialist
Specialist
Author

I have attached a sample file.

tamilarasu
Champion
Champion

Hi Jim,

Please check the attached file.

yadhunandhanan
Partner - Contributor III
Partner - Contributor III

jim_chan
Specialist
Specialist
Author

the sum of the bar chart actually not so easy....i am thinking to write it in variable.

so .. on the load script

i created

let vSum = sum(price)*100/0.5;

Table1:

load*,

if (($(vSum))<1000 ,'<1000',

if (($(vSum))<= 2000,'1001 - 2000',

if (($(vSum))<= 5000, '>5000'))) as [Price Range]

from....

I got error on my If statements.. did i write it wrong?

Rgds,

Jim

tamilarasu
Champion
Champion

Try something like,

Data:

Load Chart,

Sum(Price)*100/5 as Sales Group by Chart;         

LOAD * INLINE [

    Chart, Price

    BAR A, 1000

    BAR A, 1000

    BAR A, 1000

    BAR B, 2000

    BAR C, 3000

    BAR D , 4000

    BAR E, 5000

    BAR F, 6000

];

Final:

Load * ,

If ( Sales*100/5 <1000 ,'<1000',

  if( Sales*100/5 <= 2000 ,'1001 - 2000',

     if(Sales <= 3000 ,'2001-3000',

            if( Sales,'3001-5000', '>5000')))) as [Price Range]

            Resident Data;

Drop Table Data;

tamilarasu
Champion
Champion

Or you can simply try list box expression in front end.

If ( Sum(Price)*100/5 <1000 ,'<1000',

  if( Sum(Price)*100/5 *100/5 <= 2000 ,'1001 - 2000',

     if(Sum(Price)*100/5 <= 3000 ,'2001-3000',

            if( Sum(Price)*100/5,'3001-5000', '>5000'))))