Technical Articles
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:
- Global Variables
- DimensionsOfAggregationLevels – This is a string array to store the dimension keys of the aggregation levels in order.
- Level – This will store the actual drill level, starting from 0.
- GLOBAL_SCRIPTS
- getSelectionData
- ClearDataSourceFilter
- 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)
Great post Marton, I am not able to get your demo file working, was this developed in in 2.0?? Thanks
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
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
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
How the code will be changed if there is more than level 2? Please assist.
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:
Also is this script meant to work for display hierarchies /Backend hierarchies?
Thanks and best regards,
Regys
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:
It is defined, initialized on the application event On Variable Initialization:
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
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:
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
Hi,
The code fails if at one drill-down level there is only one value...
Regards,
Inigo
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
Hi Marton,
thank you for your sharing! Could you be so kind and reattach your application file?
Best Regards,
Alex.
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
Hi Marton,
many thanx for your time!
Alex.
Hi Marton,
Thank you for this informative, great blog!
LUMX File link has expired. Can you reattach it?
Best Regards.
Burcu
Hi Burcu, re-linked the sample file.
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:
Regards,
Rathish
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.
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.