Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
pacoli2013
Contributor

Hierarchy for my Listbox ProductGroups

Hello,

I want to create a Listbox with a Treeview for ProductGroups.

This QVD will be loaded for the Listbox

[HierProductGroup]:

LOAD

Company,

     DataLevel,

      LoadingDate,

      LevelCount,

      RootCode,

      RootName,

      LeafCode,

      LeafName,   

      Level01Code,   

     Level01Name,   

      Level02Code,

      Level02Name,

      Level03Code,

      Level03Name,

      Level04Code,

      Level04Name,

      CodePath,

      CodeName

FROM (qvd);

The fields LeafCode, Level01Code, Level02Code, Level03Code & Level04Code should be the Levels in my Listbox. Where LeafCode is the Parent and the Level xx Code are the Children. In every example I saw,  there are always Parent-ID, ChildID's, Path, '-' and HierarchyLevel. I don't have them in my QVD.

When I use the QLIKVIEW LOADStatement  I can take the Option Hierarchy : HIERARCHY(Level01Code, LeafCode, Level01Name, LeafName, Path, '-', HierarchyLevel )

When I run the script I have no Problems, only there is no Hierarchy so I can not use the TreeView option

I hope someone can help me

Thanks in regards

 

Court

6 Replies

Re: Hierarchy for my Listbox ProductGroups

You could use:

...

LeafCode & '+' & Level01Code & '+' & Level02Code & '+' & Level03Code & '+' & Level04Code as HierarchyField

...

and then using as '+' as treeview-delimiter.

- Marcus

pacoli2013
Contributor

Re: Hierarchy for my Listbox ProductGroups

Hello Marcus,

I have used your Solution, I can make a Listbox with a treeview (see jpg)

When I want to filter the ProductGroups, I only can do that on the deepest Level.

On the jpg : Productgroup (leafcode) = 10072001 and I have to go to 10072000 (=Level04Code) before the filterfunktion worksTreeView.jpg

Re: Hierarchy for my Listbox ProductGroups

I fear that's the default-behaviour from a treeview-listbox and I think a field-creation with the hierarchy-statement won't change that. Here are several links to this topic included (in the correct answer) and especially the approach from the second link: Tree View Hierarchy - select entire group? could be a workaround for you.

- Marcus

pacoli2013
Contributor

Re: Hierarchy for my Listbox ProductGroups

Hello Marcus

Thank You for your Information, it was a good help.

The only thing I couldn't find is what happens when a child-code used in the Hierarchy is empty or zero

I have zeros and empty places on different levels and I think it "kills" the hierarchy (the Parentcodes are properly filled)

Perhaps you know?

Court

Re: Hierarchy for my Listbox ProductGroups

Hi Court,

I'm not sure how NULL's (the various kinds of NULL) will affect your wished usability - if it's per default not worked like you expect it then you will need to replace them with real values like: '#NV', 'no value', 'EMPTY', '   ' or anything you like. I think you could use for this something like:

if(len(trim(LevelXCode)) = 0, 'YourReplacevalue', LevelXCode) as LevelXCode

Quite helpful is also: NULL handling in QlikView.

- Marcus

pacoli2013
Contributor

Re: Hierarchy for my Listbox ProductGroups

Hello Marcus,

I have spoken with my colleague who looks after the DataWareHouse.

He will try to to change the hierarchy-structure of the QVD's so that I can load them with a Hierarchy Loadstatement. One (new) point in the new structure will be a new column for Parent and Child ID's which is important for the loadstatement.

Thanks for your help

Court

Community Browser