Drill down / drill up

I'm trying to do the following to a bar chart.


1. User clicks on a chart bar; it drills down.

2. User clicks on chart area; it drills up.

3. There is a breadcrumb which changes to reflect drill level.

4. Clicking a higher breadcrumb drills up.


I can use the built in drill down interaction for part 1. I cannot work out the other parts with the built in functions.

There is a breadcrumb sample script that does 3 and 4 but that changes the levels rather than drilling, i.e. there is no filtering.


What is the best way to go about achieving my goal?

It seems #2 is the main issue for you here: how to drill up and separate it from the drill down interaction.

The way to do this would be to use a Hierarchy Level Parameter combined with a Hierarchy Value parameter. Drilling up simply by manipulating these parameters, so you can read their values in order to determine the current drilldown state, and then you would need to adjust appropriately to drill up, specifically, you’d have to change the level parameter up a level, and adjust the member parameter to show all members of the item you are looking at on that level.


Here is some documentation regarding modifying parameters in scripts:

http://www.dundas.com/support/support-center/support-articles/scripting/modify-a-filter-/-view-parameter-using-scripting

If you use the method described in the article to obtain references to your member parameter and level parameter, with the names memberParam and levelParam respectively, then a drill-up script would go something like below. The script is placed inside if statement and checks if e.relatedData is null, if it's null it means the users clicked on the empty area on the chart and not the actual data point.


//checks if users clicked on the empty area of the chart

if(e.relatedData==null){

// Adjust members so that current parent member becomes new member

var currentMemberValue = memberParam.parameterValue.values[0];

var parentName = currentMemberValue.parentMemberUniqueName;

if (parentName != null)

{

var parentInfo = parentName.split(".");

var newMemberValue = {

"hierarchyUniqueName" : parentInfo[2],

"levelUniqueName" : parentInfo[1] + "." + parentInfo[2], "memberKind" : "Regular", "uniqueName" : parentName }

}

else

{

var newMemberValue = {

"hierarchyUniqueName" : currentMemberValue.hierarchyUniqueName,

"memberKind" : "All",

"uniqueName" : "\\A."+currentMemberValue.hierarchyUniqueName

}

}

memberParam.parameterValue.clearTokens();

memberParam.parameterValue.clearValues();

memberParam.parameterValue.values.push(newMemberValue);

memberParam.invalidateParameterValueLastModifiedTime();

memberParam.refreshAllAdapters();

// Adjust level go up one higher unless at top already

levelParam.parameterValue.topLevelDepth = 0;

if(levelParam.parameterValue.detailsLevelDepth > 0) {

levelParam.parameterValue.detailsLevelDepth -= 1;

}

levelParam.invalidateParameterValueLastModifiedTime();

levelParam.refreshAllAdapters();

}

Thanks Ajitkaur - this is brilliant!!


I had a vague idea to do it this way but had no clue how to script it. This is perfect!

Just need a bit more help.


I don't want the final level of the drill down. So the user goes to the level where all the cities within a state are displayed and I want it to stop there. Instead, they are allowed to drill down to show just the one city, which looks silly and is unnecessary.


Can I limit this within the drill down parameter somewhere or do I have to manually script the drill down in some similar way to the drill up, so I can put an 'if' at the beginning?


Thanks

You will have to manually script the drill down interaction with the additional "if" condition so that it does not drill down to the last level of your hierarchy.

Another option is to create a custom user hierarchy to include the levels on which you wish to drill down and then promote the data cube element to the newly created user hierarchy.

Can you provide me with the drill down script? I'm not sure how to work out what the next level will be.


Thanks

I don't have a sample script on hand, but you will essentially invert the script Ajitkaur shared for the drill up: set the selected member to be the new parent member and decrease the level by one.