cancel
Showing results for 
Search instead for 
Did you mean: 

Iterate through data with getDataSelections and get the measure values

andrewbarlow1
Participant
0 Kudos

Hi,

Does anybody have the textbook way of iterating through a table of data in SAC that has 2 dimensions and 2 measures?

I want to be able to check if the dimension is say ="testCell_1" and if it is put measure 1 value into a variable and measure 2 value into a variable.

I have seen many examples of doing this but only with a single measure?

This is how I am trying to tackle it but struggling to get the measure data...

Thanks in advance for any help offered here...

var selections = table_Dummy.getDataSource().getDataSelections();
for (var a=0;a<selections.length;a++) {

	//get my 2 dimensions - works fine
	var testCell = table_Dummy.getDataSource().getResultMember("Test_CellDISPLAY_KEY",selections[a]).id;
	var state = table_Dummy.getDataSource().getResultMember("CategoryDISPLAY_KEY",selections[a]).id;
	
	var measure1Value = table_Dummy.getDataSource().getData() - help here
	var measure2Value = table_Dummy.getDataSource().getData() - help here
View Entire Topic
N1kh1l
Active Contributor
andrewbarlow1
Participant
0 Kudos

Hi nikhil_1486

This seems to work Nikhil...

I had to change the index as it looks like the second measure goes on a separate row - that is the bit that I was missing I think

var resultSet = table_Dummy.getDataSource().getResultSet();
console.log(resultSet);
for (var a = 0;a<resultSet.length;a=a+2) {
	
	var testCell = resultSet[a]["Test_CellDISPLAY_KEY"].id;
	var state = resultSet[a]["CategoryDISPLAY_KEY"].id;
        var h = resultSet[a][Alias.MeasureDimension].formattedValue;
	var m = resultSet[a+1][Alias.MeasureDimension].formattedValue;
	
	console.log(h); //I want this to be value 1 of the row with a as the row index
	console.log(m); //I want this to be value 2 of the row with a as the row index
N1kh1l
Active Contributor

andrewbarlow

I was about to comment you that the second measure goes on second row.

Glad you figured it out already.

Nikhil