cancel
Showing results for 
Search instead for 
Did you mean: 

Breakby with multiple Values

Juandres
8 - Cloud Apps
8 - Cloud Apps

Does anyone know how to have a breakby with two values in the Line chart? 
I found this community Plugin but its password protected
https://community.sisense.com/t5/knowledge/second-value-to-cartesian-charts/ta-p/9129

Any help would be greatly appreciated
@harikm007 - Any ideas?

5 REPLIES 5

Benji_PaldiTeam
10 - ETL
10 - ETL

Hi @Juandres ,

If you have 1 dimension in X-axis, 1 dimension in Break by and 2 measures as in the below screenshot, try the below approach. You may need to adjust the script if you have different number of items under each panels.

Benji_PaldiTeam_0-1709190128853.png

Use below widget script:

 


widget.on('processresult', function(w, args) {

	const seriesObj = args.result.series;

	const seriesLength = seriesObj.length

	for(i=0; i< seriesLength; i++) {

		seriesObj.push({

			name: seriesObj[i].name + '(2)',
			color: seriesObj[i].color,
			yAxis: 0,
			mask: seriesObj[i].mask,
			type: "line",
			sortData: seriesObj[i].name,
			
			data: args.rawResult.values
				.filter(item => item[1].text === seriesObj[i].name)
				.map((value, index) => ({

					color:  seriesObj[i].color,
					y: value[3].data,
					selectionData: { 0: value[0].text },
					queryResultIndex: seriesObj[i].data[index].queryResultIndex

				})
			)

		})

	}

})


widget.on("beforequery", function (se, ev) {
	$.each(ev.widget.metadata.panels[1].items, function(index, value){
		if(value.disabled == true)
		{
			var newJaql = {
				jaql  : JSON.parse(JSON.stringify(value.jaql))
			}
			ev.query.metadata.push(newJaql)
			lastIndex = ev.query.metadata.length - 1
			ev.query.metadata[lastIndex].disabled = false	
		}
	})
})

 

Result:

Benji_PaldiTeam_1-1709190281966.png

 

Here it will create additional items in the legend. You can replace '(2)' in the script to a better text that allow you to distinguish between 2 measures.

 

If you replace the type 'line' with 'column' in the script, you will get the widget as below:

Benji_PaldiTeam_2-1709190702874.png

 

 

Feel free to reach out if you have further questions, we're always happy to help 🙂
[email protected] 
Paldi Solutions, Number #1 Sisense Plugins Developer

 

Juandres
8 - Cloud Apps
8 - Cloud Apps

Hi @Benji_PaldiTeam, Thank you so much! 

Trying the script now and it just gives me a blank Graph? Anything I could be doing wrong 

Juandres_0-1709199143658.png

Juandres_1-1709199152746.png

 

 

Hi,

Are you seeing any errors in browser console?


Regards,

DRay
Community Team Member
Community Team Member

Hello @Juandres ,

I wanted to follow up to see if the solution offered by @Benji_PaldiTeam worked for you

If so, please click the 'Accept as Solution' button so that other users with the same questions can find the answer faster. If not, please let us know so that we can continue to help.

Thank you.

David Raynor (DRay)

Juandres
8 - Cloud Apps
8 - Cloud Apps

Seems like there are a tonne of HighChart Errors

Juandres_0-1709815869934.png