For any support or more customized script, contact us -  binextlevel@gmail.com

Add BreakBy filter to dashboard when click on stacked chart

If a user click on a stacked chart, Sisense will add dashboard filter for the dimension in 'Categories' panel, but not for dimension in 'Breakby' panel. By adding below script to widget, filter for breakby dimension also get added to dashboard.





widget.on('processresult', function(se, ev){
	$.each(ev.result.series, function(index, value){
		value.events = {click: function(event){
			
						var filterOptions = {
							save: true,
							refresh: true,
						}

						breakbyFilter = {
							jaql: {
								collapsed: true,
								column: ev.widget.metadata.panels[2].items[0].jaql.column,
								datatype: ev.widget.metadata.panels[2].items[0].jaql.datatype,
								datasource:ev.widget.datasource,
								dim: ev.widget.metadata.panels[2].items[0].jaql.dim,
								filter: {members: [value.name]},
								merged: true,
								table: ev.widget.metadata.panels[2].items[0].jaql.table,
								title: ev.widget.metadata.panels[2].items[0].jaql.title
							}

						}

						var isSameMemberFilterExist = _.some(prism.activeDashboard.filters.$$items,
															 function (filter) {

							var isDatasourceSame = _.isMatch(filter.jaql.datasource, breakbyFilter.jaql.datasource);

							return (filter.jaql.dim == breakbyFilter.jaql.dim &&
									filter.jaql.filter.members &&
									filter.jaql.filter.members.toString() == breakbyFilter.jaql.filter.members.toString() &&
									isDatasourceSame);
						});

						if (isSameMemberFilterExist) {
							delete breakbyFilter.jaql.filter.members;
							breakbyFilter.jaql.filter.all = true;
							prism.activeDashboard.filters.update([breakbyFilter], filterOptions);
						}else{
							prism.activeDashboard.filters.update(breakbyFilter, filterOptions);
						}
				}
			}
	})
})

Note: 'Clear Selection' button in widget title bar will not clear break-by filter

55 views0 comments

Recent Posts

See All