.periodOffset(-1) does not work

Hi, Community
I have created an aggregated form with a monthly period in order to record information on the stock level of a medication. The form includes a field which displays the stock level of the products at the start of the month, which should match the stock level at the end of the previous month.

I would like this field to be automatically populated with the quantity of medication from the end of the previous month. To do this, I have created an indicator using the formula:
#{s4ojhJUjjo4}.periodOffset(-1).

However, when testing the monthly stock level form, the indicator is not displaying any information and remains empty. I am unable to determine the cause of this problem. Can anyone help me resolve this issue?

Thank you for your post @elmoujarrade!

It seems there might be issues related to this: [DHIS2-14038] - Jira

Investigating further if the issue is in the new app only or both apps. I also tried to use preiodOffset and replicate the same use case you described above but wasn’t able to make it work.

Thanks!

1 Like

Hi, @Gassim
Thank you for your quick response
I see that the affected version is Dhis2 2.39; and I have the version Dhis2 2.36.

Hi Gassim

I am having exactly the same problem as elmoujarrade in 2023. I created a simple Indicator with [Data element ID].periodOffset(-1) but the Indicator result is always 0.

Could you please check if this function is available in 2.41.0.1?
Data Entry (Beta) version: 100.11.08
The JIRA ticket and the issue were resolved but perhaps regressed.

My use case is exactly the same as elmoujarrade: simply show the stock on hand at the end of the previous month in the current month as an Indicator.

Secondly, should the (periodOffset) functionality also be available for Data elements with Category Option Combinations? The documentation gives an example with Data elements and Program Data Elements.
I tested the function both for a Data element with or without a Category Option Combination and both return the value 0.

Thanks for your help!

Hi @elmoujarrade and @George_McGuire : thank you for bringing this issue up. We apologise for the confusion here.

At the present time, the Data Entry (Beta) app is unable to calculate various indicator expressions (including those using periodOffset). As a result, such indicators will display as 0, or will be empty, when using the Data Entry (Beta) app. This limitation only affects calculations at time of data entry; when analysing data for a data set (for example in the Data Visualizer app), these indicators will be correctly calculated.

The issue that you referenced at @George_McGuire was a fix to prevent the app from crashing when such indicators were included in a data set. Previously, if you had a non-calculable indicator in your form, the app would be unable to open the data set. As you note, the app does not crash now, but displays incorrect information about the indicator.

We have been working to be able to support the calculation of those expressions more consistently throughout the software, including the Data Entry (Beta) app, but that has not been one of our highest priorities for the upcoming release.

While we work on eventually supporting this type of calculation, we could perhaps improve the communication within the app to indicate that when an indicator calculation is not possible. If you have any specific suggestions, please let us know. Otherwise, I will forward this to attention by our design team.

Our apologies again for the inconvenience. Thank you for reaching out.

2 Likes

Hi Thomas

Thanks so much for your instant, extensive and precise answer.

For LMIS we have been using Predictors for a long time. I was not aware of the Indicator offset functionality until recently and when I came across it, I thought it may be a good alternative for “real-time” calculation for users. We do not have any specific user request from the field for providing this indicator functionality and will explore its use once it is (eventually) available.

However, I would suggest to indicate this limitation of the Indicator calculations in the user documentation, perhaps even as a “Note” (blue frame).

Manage indicators > About indicators > “Examples of .aggregationType, .maxDate, .minDate, and .periodOffset functions:”

The guidance reads “You can use the following functions in an indicator formula:”. As Indicators usually calculate “live” (in real-time) I assumed that this is the case for all indicator calculations.

I would suggest to either indicate in the table header, with a *, as “Indicator expression notes” (similarly to “SubExpression notes”) or “Notes on Indicator expressions” (similarly to "Notes on [yearlyPeriodCount]"something like: “The calculation results are only displayed in the Data Visualizer app (Analytics) while the Data Entry (Beta) will only display “0” irrespective of the actual calculation result”.