Data Label get new value on changed event


I’m looking for some best practice or tip on how to best show period over period data where the current years data may be up to a week old. For example if I last synced data on Sept. 24th, and the current date is Sept. 29th, the current years data will of course only be Jan. 1st to Sept. 24th. For a proper comparison, I also want the previous 2 years of PoP data to show Jan. 1st to Sept. 24th, not the actual YTD of Sept. 29th. Does that make sense? Otherwise previous years will have more data and the comparison is not great.

So I have the “last sync date” for my data showing in a data label. For now I have a hacky solution where I get the dataLabel.container.innerText of that label and then set the view param end date using that value. The problem is I can’t find a way to do this as soon as the data label has a value. I have tried the “Data Changed” event, but innerText seems to be empty at that point still. And the “e” event has no relatedData (null), so I don’t see how I can get this value as soon as it’s loaded.

Any non-hacky solutions would be great, or just a way to get this data label value as soon as it’s loaded. I assumed “Data Changed” event would be the way, so I may just be checking the wrong things to find the new value.


Will it work for you to put the script in the Ready event? The label text should be available to read from there. If you are setting the LastSyncDate code by script, put that in the Ready event as well.

1 Like

To get the value of a data label, I wouldn’t go down the route of hacking the innerText of the HTML. I would treat it like a chart and do dataLabel.metricSetBindings[0].dataResult.cellset and look for it in there.

(done from memory so it may be metricsetbindings)

Thanks Kelly, I had tried the Ready event and for whatever reason dataLabel.container.innerText was still empty (the data label is in the header which loads right away from a metric set). I then tried calling dataLabel.loadData() in the Ready event, and THEN the “Data Changed” event on the label properly caught the value. Again slightly hacky, but that seems to work.

And just saw the reply from David here, I will try that out now, thanks!

Ok, it’s working now and a bit less hacky. Using the document Ready event and getting the date object straight from the data label metric set works great.


I then use that date and 1st day of the current year to set the date parameter values.

Thanks everyone!