Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Bar Diagram - Each bar another function

Hello,

i want to create a bar diagram.

This diagram should contain of multiple BARS. Each BAR representing a controlnumer.

Behind each controlnumber should be a function.

I can model it within the loading script, but when i click on a bar then i dont see the underliing filters in the selection overview.

I can make it work for 1 Bar per diagramm like the following.

I create a bar diagram and add a dynamic dimension for instance:

=if(hair_color='blond','Controlnumber1')

Now the problem is - i try to add other controlnumbers. The if / else does not work for that.

e.g.:

=if(hair_color='blond','Controlnumber1',

if(hair_color='blond' AND eyes='blue' ,'Controlnumber2'))

(base formula = count(distinct personids)

The problem about this is, that controlnumber 2 gets not shown because it is a subset of controlnumber 1. QlikView seems to only allow to display the bars if they are not overlapping.

But my controlnumbers DO overlap.

So how can i do this?

Please keep in mind, that i want to maintain the connection to other tables and that when i click on a bar, i still want to see the conditions / filters for this bar (which works for a single bar).

Can anyone help me out with this?

Tags (1)
1 Solution

Accepted Solutions
MVP
MVP

Re: Bar Diagram - Each bar another function

Basically, you create a table with a n:m relation between personids and control numbers, something like

ControlNumber:

LOAD personids,

          'ControlNumber1' as ControlNumber

FROM YourTableWithPersonIDsHairColorAndEyes

WHERE hair_color = 'blond';

CONCATENATE (ControlNumber)

LOAD personids,

         'ControlNumber2' as ControlNumber

FROM YourTableWithPersonIDsHairColorAndEyes

WHERE hair_color = 'blond' AND eyes='blue';

5 Replies
MVP
MVP

Re: Bar Diagram - Each bar another function

Maybe it's just enough to order your conditions subset first:

=if(hair_color='blond' AND eyes='blue' ,'Controlnumber2',

     if(hair_color='blond','Controlnumber1')

)

Or do you want to the records to be counted in the subset as well as in the superset?

Then you need to link the records to both sets in the script.

Not applicable

Re: Bar Diagram - Each bar another function

Hello,

thanks a lot for the hint. Actually now after appliing your solution it still not works as i want it to work.

And yes, i think i want the records to be counted in the subset and the superset. Actually i would really prefer

if those BARS / SETS are completely independent from each other.

After appliing your solution i get:

5 blond blue

10 blon.

((In reality i should get 15 blond))

So basically - i think your second part should be my solution:

"Then you need to link the records to both sets in the script."

Unfortunately i do not know how to do this. Could you maybe give me a code snippet? Or explain a bit further - i am pretty much beginner level in QlikView.

antoniotiman
Honored Contributor III

Re: Bar Diagram - Each bar another function

Hi Daniel,

maybe You can use ValueList() .

See attachment.

Regards,

Antonio

MVP
MVP

Re: Bar Diagram - Each bar another function

Basically, you create a table with a n:m relation between personids and control numbers, something like

ControlNumber:

LOAD personids,

          'ControlNumber1' as ControlNumber

FROM YourTableWithPersonIDsHairColorAndEyes

WHERE hair_color = 'blond';

CONCATENATE (ControlNumber)

LOAD personids,

         'ControlNumber2' as ControlNumber

FROM YourTableWithPersonIDsHairColorAndEyes

WHERE hair_color = 'blond' AND eyes='blue';

Not applicable

Re: Bar Diagram - Each bar another function

Thanks a lot! That made it work for me! Exactly how i want it!!!! Great help apreciate it!!!

Also thanks to Antonio - tried out the solution - could not make it work like i want to with the ValueList. Maybe there is a way to use it - but i could not figure it out.

Community Browser