Accessing values of numerator and denominator of indicator via analytics API

Hi everyone,

I’m trying to work out if it is possible to access the values of the numerator and denominator of an indicator via an API call. These values show up in a downloaded csv if it is created via the visualization App, but are not returned in the JSON of an API call, even when using the includeNumDen parameter. I’m not sure if this is an issue of JSON vs. csv or API vs. vis app, but just want to know if this is possible.

An example using the 2.41 play demo. When I filter the data via the visualization app and then download a csv, I have access to the Numerator and Denominator:

Data,Period,Value,Numerator,Denominator,Factor,Multiplier,Divisor
joIQbN4L1Ok,202308,27.03,20.0,74.0,100.0,100,1
joIQbN4L1Ok,202401,34.62,9.0,26.0,100.0,100,1
joIQbN4L1Ok,202403,32.08,17.0,53.0,100.0,100,1
joIQbN4L1Ok,202404,31.43,11.0,35.0,100.0,100,1
joIQbN4L1Ok,202405,31.82,14.0,44.0,100.0,100,1
joIQbN4L1Ok,202406,44.71,38.0,85.0,100.0,100,1
joIQbN4L1Ok,202407,33.33,21.0,63.0,100.0,100,1

However, when I access the data via the API call, I do not:

https://play.im.dhis2.org/stable-2-41-0-1/api/analytics/dataValueSet.json?dimension=dx%3AjoIQbN4L1Ok&dimension=pe%3ALAST_12_MONTHS&dimension=ou%3AiGHlidSFdpu&showHierarchy=false&hierarchyMeta=false&includeMetadataDetails=true&includeNumDen=true&skipRounding=false&completedOnly=false

This returns:

"dataValues": [
    {
      "dataElement": "joIQbN4L1Ok",
      "period": "202308",
      "orgUnit": "iGHlidSFdpu",
      "value": "27.03",
      "created": "2024-08-21",
      "lastUpdated": "2024-08-21",
      "comment": "[aggregated]",
      "followup": false
    },
    {
      "dataElement": "joIQbN4L1Ok",
      "period": "202401",
      "orgUnit": "iGHlidSFdpu",
      "value": "34.62",
      "created": "2024-08-21",
      "lastUpdated": "2024-08-21",
      "comment": "[aggregated]",
      "followup": false
    }...

Any suggestions on how to access these values via the API?

Hi @mv_evans

Thanks for your detailed post.

I tried the following request:

https://play.im.dhis2.org/dev/api/analytics.json?dimension=dx%3An0GE1ISYrdM&dimension=pe%3ALAST_YEAR&showHierarchy=false&hierarchyMeta=false&includeMetadataDetails=true&includeNumDen=true&skipRounding=false&completedOnly=false&outputIdScheme=CODE&filter=ou%3AImspTQPwCqd%3BO6uvpzGd5pu%3BYuQRtpLP10I%3BDiszpKrYNg8

and it shows the numerator and indicator in the JOSN rows field:
image

I got this API call by downloading the .CSV file and checking the API request that got sent then instead of .csv, I changed it to .json
Originally, it was https://play.im.dhis2.org/dev/api/analytics.csv?dimension=dx%3An0GE1ISYrdM&dimension=pe%3ALAST_YEAR&showHierarchy=false&hierarchyMeta=false&includeMetadataDetails=true&includeNumDen=true&skipRounding=false&completedOnly=false&outputIdScheme=CODE&filter=ou%3AImspTQPwCqd%3BO6uvpzGd5pu%3BYuQRtpLP10I%3BDiszpKrYNg8 when I downloaded as CSV in the Data Visualizer app then changed CSV to JSON.

Thank you @Gassim this was exactly what I was looking for. I guess the issue was I was looking at dataValueSet but I should have been using analytics directly. Thank you again!

1 Like

Great, please post back how it all goes. Thanks!