Can an aggregate indicator display the period requested in a query?

Is it possible for an indicator to return the period requested in an analytics query?

Why would I want to do this?

I have an indicator that fetches the firstNonNull value from the last three periods. Like this.

firstNonNull(#{element}, #{element}.periodOffset(-1), #{element}.periodOffset(-2))

This works great, but it would also be really useful for end users to know what period this was derived from.

If the dataset itself is yearly I could minus the offset from the queried period and this would return the year that the data element was derived from.

Is this possible, or is there a simpler way to achieve this logic? Ideally I would like to go back even further than three periods, but I have limited it to this for ease of managing the indicators and also to reduce the intensity of the query.

1 Like

Hi thanks for your post and question!

The idea is clear and maybe the suggestion you posted is the solution. I have one suggestion but I’m not sure if it will fit your need.

Maybe a Validation Notification could help here because you could set a notification and add ‘current date’ in the notification? But I’m not sure then how it’d be included in the analytics apps for example?

1 Like

Ultimately this is for use in an external program so the data needs to be accessible via the api.

If the indicators are not able to do this then I am sure I can build an SQL view that achieves the same function, but I am not sure what the performance for this would be like.

I have been meaning to familiarize myself with the analytics tables anyway, so I might go down that path. I was hoping that there was a “vanilla” solution but I am sure I can find a workaround if needs be,

Since this is for external program maybe using validation API is another approach? Data Validation - DHIS2 Documentation

1 Like

I’ll give that a go and report back. Thanks

1 Like