Constructs a dimensions expression for analytics queries based on specified property, operator, and values.
Details
DHIS2 organizes data using multiple dimensions, each with a unique identifier and a set of items that represent specific data points within that dimension.
Data elements (dx): Indicators, data set reporting rate metrics, data element operands, program indicators, program data elements, program attributes, validation rules.
Periods (pe): ISO periods (e.g., 202401) and relative periods (e.g., LAST_WEEK).
Organisation unit hierarchy (ou): Specific health facilities, districts, countries, and keywords for user location or its sub-units.
Category option combinations (co): Category option combo identifiers.
Attribute option combinations (ao): Category option combo identifiers.
Categories: Category option identifiers.
Data element group sets: Data element group identifiers.
Organisation unit group sets: Organisation unit group identifiers.
The infix operator used for filter and dimension includes:
%.d%
: Infix operator for constructing dimension filters. Equivalent to callinganalytics_dimension("dimension", ...)
.%.f%
: Infix operator for constructing filter filters. Equivalent to callinganalytics_dimension("filter", ...)
.
Examples
# Create a dimension for data element "DE_1234"
analytics_dimension('dimension', "dx", "DE_1234")
#> <spliced>
#> $dimension
#> [1] "dx:DE_1234"
#>
# Equivalent to the expression above
dx %.d% "DE_1234"
#> <spliced>
#> $dimension
#> [1] "dx:DE_1234"
#>
# Create a filter dimension for the period of January 2024
pe %.f% "202401"
#> <spliced>
#> $filter
#> [1] "pe:202401"
#>
# Create filter dimension for periods "202401" and "202402":
analytics_dimension("filter", "pe", c("202401", "202402"))
#> <spliced>
#> $filter
#> [1] "pe:202401;202402"
#>