Skip to Content

In this short post I would like to share a drill-down script for Lumira Designer (formerly known as Design Studio). It’s not rocket-science, but hopefully would save some time for you.

The demo is on the well known clothing company eFashion. Operating in the US and doing especially well in Texas!

The original code came from Axel Blaze, posted here. But unfortunately he shared the code only as screenshots and had some minor issues as well. It was a bit cumbersome.

So here’s the updated code as text to easly copy and paste.

These are the main components of the solution:

  1. Global Variables
    1. DimensionsOfAggregationLevels – This is a string array to store the dimension keys of the aggregation levels in order.
    2. Level – This will store the actual drill level, starting from 0.
  2. GLOBAL_SCRIPTS
    1. getSelectionData
    2. ClearDataSourceFilter
  3. Chart “On Select script”

Please find the scripts below and a link to an example at the buttom.

DimensionsOfAggregationLevels

DimensionsOfAggregationLevels = ["OBJ_218", "OBJ_166", "OBJ_376"];
  • On the Properties view you need to change the Array property to true
  • You need to set the initial values at the APPLICATION \ On Variable Initialization script
  • To get the OBJ_218 and like, you may use a trick: on the charts “On Select” event \ type in DS_1.getDimensionText(dimension) and while “dimension” is still highlighted hit Ctrl+Space. “Content assistance” will list all of the dimensions available on the dataset with the object keys. This could be handy if the key is a longer asjdjsndfkbweasd

getSelectionData

Input parameters:

Name / Type / Array

  • DS / DataSourceAlias / false
  • Chart / VizFram / false
  • PrimaryDimension / String / false
  • FilterDimension / String / false
  • FilterValue / String / false

Script:

var STR = "";
 DS.moveDimensionToRows(PrimaryDimension, 0);
 DS.setFilter(FilterDimension, FilterValue);
 DS.removeDimension(FilterDimension);
 Chart.clearSelection();
 Chart.setDataSource(DS);
 var MEM = DS.getMembers(PrimaryDimension, 100);
 MEM.forEach(function(element, index) {
 STR = STR + '"' + element.text + '"';
 });
 STR = "{" + '"' + PrimaryDimension + '":' + "[ " + STR + " ]" + "}";
 return STR;

ClearDataSourceFilter

Input parameters:

Name / Type / Array

  • DS / DataSourceAlias / false
  • Chart / VizFram / false
  • FilterDimension / String / true

Script:

//APPLICATION.alert("No more drill down. Going back to initial level."); // Optional alert
 Chart.clearSelection();
 FilterDimension.forEach(function(element, index) {
 DS.clearFilter(element);
 DS.removeDimension(element);
 });
 DS.moveDimensionToRows(FilterDimension[0], 0);
 Chart.setDataSource(DS);
 Level = 0;

Chart On Select

Script:

if (Level < 2){
var selected = CHART_1.getSelectedMember(DimensionsOfAggregationLevels[Level]).internalKey;
CHART_1.setDataSelection(GLOBAL_SCRIPTS_1.getSelectionData(DS_1, CHART_1,  DimensionsOfAggregationLevels[Level+1],DimensionsOfAggregationLevels[Level], CHART_1.getSelectedMember(DimensionsOfAggregationLevels[Level]).internalKey));
Level = Level+1;
}
else
{
GLOBAL_SCRIPTS_1.ClearDataSourceFilter(DS_1, CHART_1, DimensionsOfAggregationLevels);
}

 

Example: Lumira Designer Drill Down Demo.lumx

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

    1. Marton Horvath Post author

      Hi Michael,

      Yes. I have just re-tested the version I have uploaded with Lumira 2.0 and it performed correctly.

      The exact version number: 20.2.3

      Do you get any error message?

      Regards,

      Marton

      (0) 
      1. Anand Tiwari

        Hi Marton,

        Your post is quite on point, just make one addition to on select script in else clause.
        Add Level = 0;

        without this the script will not work more than once.

        Thanks
        Anand

        (0) 
        1. Marton Horvath Post author

          Hi Anand,

           

          Thanks for the feedback. I have re-checked the code, but looks fine for me. Level=0; is in the else clause through ClearDataSourceFilter global script call.

          Also tested it: worked well drilling down and back multiple times, not only once.

           

          Regards,

          Marton

          (0) 
  1. Regys Mene

    Hi Marton,

    great post! 🙂 However, when I want to drill down to the second level, it shows me the error that the Dimension “OBJ_166”: cannot be found. Could you please let me know where should I substitute the OBJ_166 with my actual dimensions?

    My Chart Script:

    if (Level < 2){
    var selected = CHART_2.getSelectedMember(DimensionsOfAggregationLevels[Level]).internalKey;
    CHART_2.setDataSelection(GLOBAL_SCRIPTS_1.getSelectionData(DS_1, CHART_2, DimensionsOfAggregationLevels[Level+1],DimensionsOfAggregationLevels[Level], CHART_2.getSelectedMember(DimensionsOfAggregationLevels[Level]).internalKey));
    Level = Level+1;
    }
    else
    {
    GLOBAL_SCRIPTS_1.ClearDataSourceFilter(DS_1, CHART_2, DimensionsOfAggregationLevels);
    }

     

    Also is this script meant to work for display hierarchies /Backend hierarchies?

    Thanks and best regards,

    Regys

    (0) 
    1. Marton Horvath Post author

      Hi Regys,

      OBJ_166 is stored in the DimensionsOfAggregationLevels variable (string array). As the name tries to tell, it stores the aggregation levels in order.

      In the example:

      • State = OBJ_218
      • City = OBJ_166
      • Store name = OBJ_376

      It is defined, initialized on the application event On Variable Initialization:

      • DimensionsOfAggregationLevels = [“OBJ_218”, “OBJ_166”, “OBJ_376”];

      You should modify this according to your aggregation levels.

      The script meant to work (and has been tested) on a relation data source (on top of simple universe dimensions), like eFashion.

      Regards,

      Marton

      (0) 
  2. Abhishek Kshatriya

    HI,

    Can you please help resolving below issue:

    I am getting below Errors:

    Chart:Cannot convert from “VizFrame” to “DataSourceAlias”

    Data source:Cannot convert from “DataSourceAlias” to “String”

     

    My Chart Script:

     

    if (Level < 2){
    var selected = CHART_1.getSelectedMember(DimensionsOfAggregationLevels[1]).internalKey;
    CHART_1.setDataSelection(GLOBAL_SCRIPTS_1.getSelectionData(DS_BY_REGION_TOR, CHART_1, DimensionsOfAggregationLevels[2],DimensionsOfAggregationLevels[Level], CHART_1.getSelectedMember(DimensionsOfAggregationLevels[1]).internalKey));
    Level = Level+1;
    }
    else
    {
    GLOBAL_SCRIPTS_1.ClearDataSourceFilter(DS_BY_REGION_TOR, CHART_1, DimensionsOfAggregationLevels);
    }

     

    (0) 
    1. Marton Horvath Post author

      Hi Abhishek,

      Please check all data types are as it should be in your getSelectionData function.

      My theory for your first error message:

      It seems that Chart input parameter is set to “DataSourcAlias”.

      So when the function receives a VizFrame incoming parameter (CHART_1) from your OnClick script, it throws an error because it is not able to convert to DataSourceAlias. But it should not. The “expected” type should be set to VizFrame.

       

      Note: you replaced the variable Level with constant values. You will need to change it back to get it working dynamically.

       

      Regards,

      Marton

      (0) 

Leave a Reply