Hello,
We set color to specific value configured in "Measures".
Report works ok if I predefine 2 Measures where I want to color the second one "v1" (based on the array).
If my user go to Fields->remove the first measure "v0", then "v1" becomes the new "v0" and my function fails.
How do I retrieve the "v[NNN]" value based on the name of a specific "Measure" so that, instead of setting "result.data[c].v1", I use something like "result.data[c].MY_MEASURE.value" or something similar?
Here is my code:
function onReportComplete() {
pivot.getData({}, function(result) {
var column = "";
var record = new Array();
var minValue = 0;
var maxValue = 0;
//Get all rows event totals and repeated lines
for (var i = 0; i < result.data.length; i++) {
if(result.data[i].r0){
if(column != result.data[i].r0){
column = result.data[i].r0;
record.push(column);
}
}
}
//Get only unique rows
record = record.unique();
for (var r = 0; r < record.length; r++) {
minValue = Number.MAX_VALUE;
maxValue = Number.MIN_VALUE;
for (var c = (record.length+1) ; c < result.data.length; c++) {
if(result.data[c].r0 && !isNaN(parseFloat(result.data[c].v1)) ){
if(record[r] == result.data[c].r0 ){
// Here we assume that values evaluated are in "v1" position as there are 2 Measures in the report
// If I take out the first value in "Measures" my value will be in "v0" and logic will fail
// How do I set dinamically the v[n]?
minValue = Math.min(minValue,result.data[c].v1);
maxValue = Math.max(maxValue,result.data[c].v1);
}
}
}
Min[r] = minValue;
Max[r] = maxValue;
}
pivot.refresh();
});
}
Check the images attached.
Thanks.
@Ed
Hello,
Thank you for contacting us.
It would be useful for our investigation if you could provide additional details about the logic on which the formatting is based. It would allow us recommending the best solution for your case.
We are looking forwards to hearing from you.
Best regards,
Illia