Hey Martin,

I suggest that you use (if necessary create) an organisation unit group
set-based dimension in your request. The group in question needs to be part
of the group set. In this case we can use the org unit group set called
"facility type" as an example, where CHC is one of the groups.

Facility type - org unit group set - id: J5jldMd8OHv
CHC - org unit group - id: J5jldMd8OHv:CXw2yu5fodb

Now this group set dimension can be used as a filter. In your example
above, the API correctly returns a message explaining that a single
dimension cannot be used as both dimension and filter.

We now have this URL which I think gives you what you want:

https://play.dhis2.org/demo/api/analytics.json?dimension=dx:fbfJHSPpUQD&dimension=pe:LAST_12_MONTHS&dimension=ou:ImspTQPwCqd
*&filter=J5jldMd8OHv:CXw2yu5fodb*



best,

Lars





On Fri, Jan 20, 2017 at 4:15 PM, Martin Van Aken <mar...@joyouscoding.com>
wrote:

> Hello everyone,
> I've a question on the analytics API. If I want to get a result for a
> single org unit, I can do something like this:
>
> https://play.dhis2.org/demo/api/analytics.json?dimension=
> dx:fbfJHSPpUQD&dimension=pe:LAST_MONTH&dimension=ou:ImspTQPwCqd
>
> (in this case, asking for the ANC 1st visit result for the last month for
> the Sierra Leone country).
>
> This is actually giving me the aggregation of all the org unit in the
> country, as per the documentation:
>
> "For the organisation unit dimension the dimension items are the
> organisation units and their sub-hierarchy - data will be aggregated for
> all organisation units below the given organisation unit in the hierarchy."
>
> Now in my case, I would like to run the same query (result for the whole
> country), but limiting the org unit to a given group - let's say the CHCs.
> The thing is: I don't want the results for each CHC, but still a single
> result at the top level - I just want to include only the CHC in the
> aggregation.
>
> Can this be expressed using the DHIS2 API? I've the feeling I could use a
> filter there, but could not manage to make it work.
>
> Attempting to add filter=ou:OU_GROUP-CXw2yu5fodb to the above query
> result to the API returning an error as: "Dimensions cannot be specified as
> dimension and filter simultaneously" - and I don't see how I can say "give
> me the aggregate for all units under Sierra Leone that are part of the CHC
> group".
>
> Any help or pointer would be most welcome.
>
> Martin
>
> --
> *Martin Van Aken - **Freelance Enthusiast Developer*
>
> Mobile : +32 486 899 652
>
> Follow me on Twitter : @martinvanaken <http://twitter.com/martinvanaken>
> Call me on Skype : vanakenm
> Hang out with me : mar...@joyouscoding.com
> Contact me on LinkedIn : http://www.linkedin.com/in/martinvanaken
> Company website : www.joyouscoding.com
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-users
> Post to     : dhis2-users@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help   : https://help.launchpad.net/ListHelp
>
>


-- 
Lars Helge Øverland
Lead developer, DHIS 2
University of Oslo
Skype: larshelgeoverland
l...@dhis2.org
http://www.dhis2.org <https://www.dhis2.org/>
_______________________________________________
Mailing list: https://launchpad.net/~dhis2-users
Post to     : dhis2-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to