cancel
Showing results for 
Search instead for 
Did you mean: 

Script reading/using a subset of whole Table Widget

turtleData123
8 - Cloud Apps
8 - Cloud Apps

Hey all,

I'm running into an issue with my current task:

I'm trying to add a column to a table widget containing values calculated using values provided in the table itself using 'edit code.' The final product would have a column that indicates whether that row is the maximum value compared to similar rows with different dates. IE, if I had to sort City, Store and Department for a company by revenue numbers by date, which date has the maximum revenue value by those aggregates, basically. To do this, I'm looping through the dataset, and trying to compare each value to a stored temporary max value. 

The issue arises here, looping through the data. When I log to the console the sites, or the dataset itself, the console shows 220 values, but the dataset has around 7800 rows, which should be what the console reports, no? I know this is an issue, because when I attempt to grab unique sites from the set, it returns only 22 sites, but I know there are roughly 38 or so unique sites in the set.

 

widget.on('ready', function(sender,event) {
	setTimeout(function() {
	var queryResult = sender.rawQueryResult;
	var dataSet = queryResult.values;
	var dates = [];
	var sites = [];
	var weights = [];
	
	$.each(dataSet, function() {
		var date = this[0].text;
		var site = this[1].text;
		var weight = this[2].data;
		dates.push(date);
		if (!sites.includes(site)) {
			sites.push(site); 
		} else {} ;
		weights.push(weight);
	});
	
	
	console.log(sites);
	console.log(queryResult);
	console.log(dataSet);
	}, 500)
});

 

 I tried adding this timeout function to give the set time to load but it didn't seem to change anything. Also, I get the "Uncaught TypeError: Cannot read properties of null (reading'values') at eval" error, pointing to that line which reads the queryResults values, so I'm wondering if this error occurs at that 221st row and prevents the script from reading anything further, hence why I am receiving only 220 rows from the set rather than the whole set

Anything helps, thanks

Table widget, not Pivot

Sisense version 2023.11

1 ACCEPTED SOLUTION

DRay
Community Team Member
Community Team Member

Thank you for getting back to me. Yes, I wanted to make sure that a stand-alone widget without a script was able to pull over the 220 rows you are getting with the script.

Can you open a support ticket for this? They will be able to work with you directly to determine the cause. This will require a more in-depth review than we can provide here.

David Raynor (DRay)

View solution in original post

4 REPLIES 4

DRay
Community Team Member
Community Team Member

Hi @turtleData123,

Thank you for your question. Are you able to pull the full data if you use a stand-alone widget? I would like to narrow down the issue to either the script, or the data.

 

David Raynor (DRay)

Hey DRay, thanks for the reply! Are you asking if a widget without any code associated pulls all of the data? If so the answer is yes

DRay
Community Team Member
Community Team Member

Thank you for getting back to me. Yes, I wanted to make sure that a stand-alone widget without a script was able to pull over the 220 rows you are getting with the script.

Can you open a support ticket for this? They will be able to work with you directly to determine the cause. This will require a more in-depth review than we can provide here.

David Raynor (DRay)

Thanks for the attempt, I appreciate it - I'll open a ticket and get some help from there.