Skip to Content
Technical Articles
Author's profile photo Marton Horvath

Lumira Designer Drill Down

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 (Note: updated the link, pointing to Google drive, download lumx, don’t extract)

Assigned Tags

      19 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Great post Marton, I am not able to get your demo file working, was this developed in in 2.0?? Thanks

      Author's profile photo Marton Horvath
      Marton Horvath
      Blog 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

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Marton Horvath
      Marton Horvath
      Blog 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

      Author's profile photo Danny Choi
      Danny Choi

      How the code will be changed if there is more than level 2? Please assist.

       

      Author's profile photo Regys Mene
      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

      Author's profile photo Marton Horvath
      Marton Horvath
      Blog 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

      Author's profile photo ABHISHEK KSHATRIYA
      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);
      }

       

      Author's profile photo Marton Horvath
      Marton Horvath
      Blog 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

      Author's profile photo Inigo Montoya Irigoyen
      Inigo Montoya Irigoyen

      Hi,

      The code fails if at one drill-down level there is only one value...

      Regards,

      Inigo

      Author's profile photo Venkata
      Venkata

      Hi Marton,

       

      The lumx file which you have shared is not working,Can you please re-share the lumx file it would be helpful,

      Regards,

      Venkat

      Author's profile photo Alexander Keshishian
      Alexander Keshishian

      Hi Marton,

      thank you for your sharing! Could you be so kind and reattach your application file?

      Best Regards,

      Alex.

      Author's profile photo Marton Horvath
      Marton Horvath
      Blog Post Author

      Hi Alex,

      Sorry for the slow response, if by any chance you may still be interested, I just re-linked the sample file.

      Regards,

      Marton

      Author's profile photo Alexander Keshishian
      Alexander Keshishian

      Hi Marton,

      many thanx for your time!

      Alex.

      Author's profile photo Burcu Aksoy
      Burcu Aksoy

      Hi Marton,

      Thank you for this informative, great blog!

      LUMX File link has expired. Can you reattach it?

       

      Best Regards.

      Burcu

      Author's profile photo Marton Horvath
      Marton Horvath
      Blog Post Author

      Hi Burcu, re-linked the sample file.

      Author's profile photo Rathish Pillai
      Rathish Pillai

      Hi Marton,

      The post is good. But the ClearDataSourceFilter script is not working if the dimension at last level is having only 1 member. It is showing error as below.

      Error: Dimension "ABC" in selection "{"ABC":["123"]}" could not be found in data source.

      But if the dimension is having multiple members then it is going back to initial level.

      My ClearDataSourceFilter script:

      Chart.clearSelection();
       FilterDimension.forEach(function(element, index) {
       DS.clearFilter(element);
       DS.removeDimension(element);
       });
       DS.moveDimensionToRows(FilterDimension[0], 0);
       DS.moveDimensionBefore("0CALYEAR", FilterDimension[0]);
       Chart.setDataSource(DS);
       Level = 0;

      Regards,

      Rathish

       

       

      Author's profile photo Ali Malik
      Ali Malik

      Hi Marton,

      Thank you so much for the solution, I have a question this code works fine when the dimension has multiple members, but when it only has one member it fails. do you have a solution for that?

      Attached is a screenshot of the example and where it fails.

       

      Thank you, will wait for your reply.

      Author's profile photo LTI BW
      LTI BW

      Based on Marton’s blog, I tried the below solution without using global scripts & global variable.  I just used 2 levels of drilldown. fiscal year -> fiscal period -> purchasing group.  Below code is  written on script for event “On Select” for CHART, worked without any hassle for me.

      var V1 = CHART_1.getSelectedMember(“0FISCYEAR”).internalKey;
      
      var V2 = CHART_1.getSelectedMember(“0FISCPER”).internalKey;
      
      var V3 = CHART_1.getSelectedMember(“0PUR_GROUP”).internalKey;
      
      if ( V1 != ‘(ALL_MEMBERS)’)
      {
      DS_1.moveDimensionToRows(“0FISCPER”,0);
      DS_1.setFilter(“0FISCYEAR”, V1);
      DS_1.removeDimension(“0FISCYEAR”);
      CHART_1.clearSelection();
      CHART_1.setDataSource(DS_1);
      }
      else if (V2 != ‘(ALL_MEMBERS)’)
      {
      DS_1.moveDimensionToRows(“0PUR_GROUP”,0);
      DS_1.setFilter(“0FISCPER”, V2);
      DS_1.removeDimension(“0FISCPER”);
      CHART_1.clearSelection();
      CHART_1.setDataSource(DS_1);
      }
      else if (V3 != ‘(ALL_MEMBERS)’)
      {
      DS_1.moveDimensionToRows(“0FISCYEAR”,0);
      DS_1.clearFilter(“0FISCYEAR”);
      DS_1.clearFilter(“0FISCPER”);
      DS_1.removeDimension(“0PUR_GROUP”);
      CHART_1.clearSelection();
      CHART_1.setDataSource(DS_1);
      }