cancel
Showing results for 
Search instead for 
Did you mean: 

Filter by both the dimension and the break by on the dashboard

ScheurK
8 - Cloud Apps
8 - Cloud Apps

Hi all,

 

Let's say I have a bar chart in my dashboard displaying number of customers over time with customer segments (small, regular, top) in the break by field. When I turn on 'widget affects dashboard filters' I noticed that the dashboard filters are not affected by whatever is in the break by field.

 

Is there a widget script to create this behavior? E.g., when a user clicks on the top segment in february 2022 then all other widgets in the dashboard show the values for top customers in february 2022.

Kind regards,
Kevin

1 ACCEPTED SOLUTION

harikm007
12 - Data Integration
12 - Data Integration

@ScheurK ,

Please try this script (Reference)

 

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);
																	});
			console.log(isSameMemberFilterExist)
			
								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 may not clear break-by filter

-Hari

View solution in original post

2 REPLIES 2

harikm007
12 - Data Integration
12 - Data Integration

@ScheurK ,

Please try this script (Reference)

 

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);
																	});
			console.log(isSameMemberFilterExist)
			
								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 may not clear break-by filter

-Hari

Thanks!