Hi guys.
On a dashboard of mine, I'm using data labels as KPI's where both the text colour in the label (and a state indicator in the form of triangles using a copied metric set) change colour when compared to the 12 month average.
Now on the surface this is simple. I merely only needed the metric sets to have measures of the values of the last 12 months (sorted in descending order) and then compared to the moving annual average (or MAA) over 12 months by using the "add period over period" data tool.
But unfortunately I also need to be able to filter down the month (within the last year) that the data was collected in with a click event. That filter iteslf was not difficult to implement by changing parameters.
But unfortunately; when selecting a new month, thecalculation period of 12 month MAA also moves back to begin at the month of selection (as the data in the metric set also moves to the selected month). What I need is for that MAA to remain constant from the latest reported month (and for those state comparisons to continue comparing the selected month with the average up until the latest month)
I'm already using another data label as a KPI displaying merely the MAA over the last year that is not sublected to any filtering.
So my question is: How do I go about using for a comparer in the filtered data label; the data from the metric set of the fixed MAA in the non-filterd data label?
I've tried using a dummy field (a measure with a constant value of 0) in the metric set of the filtered data label and then usig scripting to populate the cells of this field with the value in the metric set of the non-filtered data label. But that doesnt actually update the values in the data preview.
I've seen this article in the help files where usage is made of a "DataRetrievalServĂŻce:
https://www.dundas.com/support/support-center/support-articles/scripting/read-data-from-a-visualization-by-script
I follow that in this example; a button is implmented that retrieves cells of data from a visualization's metric set. But it pretty much loses me when I get to the following line:
"Once the data has been retrieved in the CellSet, the tuples can be accessed using the following code snippet:
1 |
CellSet.rows.forEach( function (row) { //your code }" |
Because I honestly have no idea what sort of code I should put in this function.
Could someone please at least point me in the right direction on this?