What are the possible cause of Expression is not well-formed error for indicators

I created some indicators for some DE I am working on. When I run the Data Integrity test using the Data Administration app, I got the error Invalid indicator numerators and Invalid indicator denominators. when I inspect one of the indicator in network tab, it’s still the same error I got. Meanwhile, the same pattern of indicator works in over 50 indicators. The ones that fails is like 15% of the total. I am unable to debug the error because the error message does not provide any details. Besides, it’s such a simple indicator in some cases just a numerator and a 1 factor denominator.

EDITED

I am including an example below. Here is one of several examples I imported. Some of it don’t have the error while a few does. Besides, I did confirm that the numerator uid/id is created for the referenced data element.

    {
        "denominator": "1",
        "denominatorDescription": "1",
        "description": "Number of clients who received treatment for HIV/AIDS",
        "id": "qauKvCkJeqf",
        "indicatorType": {
            "id": "kHy61PbChXr"
        },
        "legendSets": [],
        "name": "Number of patients who received treatment for HIV/AIDS",
        "numerator": "#{6KjtJgJ8bqB}",
        "numeratorDescription": "Number of patients who received treatment for HIV/AIDS",
        "sharing": {
            "external": false,
            "owner": "M5zQapPyTHU",
            "public": "rw------",
            "userGroups": {},
            "users": {}
        },
        "shortName": "Patients who received treatment for HIV/AIDS",
        "translations": []
    }

Hi @jetisco4u

Please check if you ran the analytics tables export in Data Administration app. It will probably help to clear the cache (and to make sure 100% it’s not a cache issue, try Guest Mode).

If you did all the above, would you please share the Catalina.out log (without the sensitive into)?

Thank you!

I get the error after running data integrity. Out of 90 indicators, it was reported that 12 numerator and 4 denominator have Expression is not well-formed from the maintenance app. I followed your suggestion above clear the cache and the issue persist. Although I don’t know what you mean by try the guest mode.

I checked the log and got the below message.

cluster-core-1  | * WARN  2022-09-29T09:46:58,111 Data Element or DataElementOperand must have a uid #{3XkcV4hFxbW} parsing expression '#{3XkcV4hFxbW}' (DefaultExpressionService.java [http-nio-8080-exec-6]) IDt6mcIeoZYqikYB047LGDVvLNyM3XL/0sGxQoMuDDjKI=
cluster-core-1  | * WARN  2022-09-29T09:46:58,112 Data Element or DataElementOperand must have a uid #{3XkcV4hFxbW} parsing expression '#{3XkcV4hFxbW}' (DefaultExpressionService.java [http-nio-8080-exec-6]) IDt6mcIeoZYqikYB047LGDVvLNyM3XL/0sGxQoMuDDjKI=
cluster-core-1  | * WARN  2022-09-29T09:46:58,114 Data Element or DataElementOperand must have a uid #{3XkcV4hFxbW} parsing expression '#{3XkcV4hFxbW}' (DefaultExpressionService.java [http-nio-8080-exec-6]) IDt6mcIeoZYqikYB047LGDVvLNyM3XL/0sGxQoMuDDjKI=
cluster-core-1  | * WARN  2022-09-29T09:46:58,114 Data Element or DataElementOperand must have a uid #{3XkcV4hFxbW} parsing expression '#{3XkcV4hFxbW}' (DefaultExpressionService.java [http-nio-8080-exec-6]) IDt6mcIeoZYqikYB047LGDVvLNyM3XL/0sGxQoMuDDjKI=
cluster-core-1  | * WARN  2022-09-29T09:47:57,162 Data Element or DataElementOperand must have a uid #{3XkcV4hFxbW} parsing expression '#{3XkcV4hFxbW}' (DefaultExpressionService.java [http-nio-8080-exec-14]) IDt6mcIeoZYqikYB047LGDVvLNyM3XL/0sGxQoMuDDjKI=
cluster-core-1  | * WARN  2022-09-29T09:47:57,162 Data Element or DataElementOperand must have a uid #{3XkcV4hFxbW} parsing expression '#{3XkcV4hFxbW}' (DefaultExpressionService.java [http-nio-8080-exec-14]) IDt6mcIeoZYqikYB047LGDVvLNyM3XL/0sGxQoMuDDjKI=
cluster-core-1  | * WARN  2022-09-29T09:47:57,163 Data Element or DataElementOperand must have a uid #{3XkcV4hFxbW} parsing expression '#{3XkcV4hFxbW}' (DefaultExpressionService.java [http-nio-8080-exec-14]) IDt6mcIeoZYqikYB047LGDVvLNyM3XL/0sGxQoMuDDjKI=
cluster-core-1  | * WARN  2022-09-29T09:47:57,166 Data Element or DataElementOperand must have a uid #{3XkcV4hFxbW} parsing expression '#{3XkcV4hFxbW}' (DefaultExpressionService.java [http-nio-8080-exec-14]) IDt6mcIeoZYqikYB047LGDVvLNyM3XL/0sGxQoMuDDjKI=

Please search for the one that has “3XkcV4hFxbW” and share the template you are using to import maybe it will give us insight. Thanks!

@Gassim Here is the particular object for the indicator with this DE.


        {
            "annualized": false,
            "attributeValues": [],
            "code": "AGG_IND_TAV_1",
            "denominator": "1",
            "denominatorDescription": "1",
            "description": "Number of rape cases",
            "id": "DYZjNWzGX3h",
            "indicatorType": {
                "id": "kHy61PbChXr"
            },
            "legendSets": [],
            "name": "KPI - Rape cases",
            "numerator": "#{3XkcV4hFxbW}",
            "numeratorDescription": "Number of rape cases",
            "sharing": {
                "external": false,
                "owner": "M5zQapPyTZI",
                "public": "rw------",
                "userGroups": {},
                "users": {}
            },
            "shortName": "Number of rape cases",
            "translations": []
        },

The DE referenced is ls imported like:


        {
            "code": "AGG_DE_TAV_1",
            "id": "3XkcV4hFxbW",
            "name": "Number of rape cases",
            "shortName": "Rape cases",
            "aggregationType": "SUM",
            "domainType": "AGGREGATE",
            "displayName": "Number of rape cases",
            "publicAccess": "rw-r-----",
            "displayShortName": "Rape cases",
            "externalAccess": false,
            "valueType": "INTEGER_ZERO_OR_POSITIVE",
            "dimensionItem": "3XkcV4hFxbW",
            "zeroIsSignificant": true,
            "displayFormName": "Number of rape cases",
            "favorite": false,
            "dimensionItemType": "DATA_ELEMENT",
            "optionSetValue": false,
            "access": {
                "read": true,
                "update": true,
                "externalize": true,
                "write": true,
                "delete": true,
                "manage": true
            },
            "categoryCombo": {
                "id": "bjDvmb4bfuf"
            },
            "sharing": {
                "owner": "M5zQapPyTZI",
                "userGroups": {},
                "external": false,
                "public": "rw-r-----",
                "users": {}
            },
            "user": {},
            "favorites": [],
            "dataSetElements": [
                {
                    "dataElement": {
                        "id": "3XkcV4hFxbW"
                    },
                    "dataSet": {
                        "id": "qVRpBykxzYl"
                    }
                }
            ],
            "userGroupAccesses": [],
            "dataElementGroups": [
                {
                    "id": "hXJ30SEIt94"
                }
            ],
            "attributeValues": [],
            "userAccesses": [],
            "legendSets": [],
            "aggregationLevels": []
        }

Thanks! And just a quick question, your user does have all necessary access right to the DE?


As for clearing the cache, first try using guest mode please:
If you are using Chrome, you can click on Guest from the profile picture, please see screenshot:

@Gassim yes I have user access. I was testing it as admin. I removed the user access details when I wanted to post it to reduce the length of the object. I tried in guest mode and it’s still the same error message for the indicator - Expression is not well-formed.

It’s difficult for me to debug because similar expression of formula work for other indicators.

1 Like

Would it be possible to share the file you are using with only one indicator that’s not working? To test and reproduce this on play.dhis2.org

Thanks!

it’s a big file with over 100 Indicators. I will have to narrow it down to those not working

1 Like

Yes, thanks! Maybe just one that’s not working :smiley:

This script might help: dhis2-utils/tools/dhis2-metadata-package-validator at master · dhis2/dhis2-utils · GitHub as it checks for some common mistakes in Program Rules / Expressions.

@jaime.bosque thanks for the reference. I am not good with Python. How do I install this to use in command line?

Hi @jetisco4u .

It is going to depend on your operative system and other factors. This is a bit out of the scope of DHIS2 and I don’t have much time to explain but you can find tons of resources online. Please check and let us know in case you run into issues while running the tool. Probably @ctejo or @stratosilva can help you with the tool.

Cheers.

While I’m not sure if this applies precisely to this use case, I’d wonder if it isn’t the fact that your numerator doesn’t have a distinction of where its coming from.
“numerator”: “#{3XkcV4hFxbW}”,
I’d normally expect this to be something more like:
#{wGNtUtGJ9eY.3XkcV4hFxbW}

Where the first uid is the programStage it exists, and the second the specific DE within that program stage.

1 Like

@Matthew_Boddie thanks for the response. I am creating indicator for aggregate data and not program indicator. The expression I used work in some cases and didnt work in others with similar approach that is why it is difficult for me to figure out the problem.

2 Likes

Understood!

1 Like

Hi @jetisco4u

I asked @jason for support on this, he said “6KjtJgJ8bqB” is not a valid dhis2 UID so he suspects that’s throwing off the indicator parser.

@jason any idea why it’s not a valid UID? Because I created my DE and indicator from a json file. I manually assign a alphanumeric 11 character to the DE and indicators which was auto generated.

1 Like

@jetisco4u an app developer once was facing an issue generating UIDs using the API and received a solution, it might help give you an idea: Issue creating a tracked entity instance with a generated UID via API - #6 by josephatjulius

@jason:

it’s because sometimes UIDs become database column names
and they must start with a letter or underscore
so that’s why all UIDs must start with letter

Thanks @jason I think this will do for me. I have to review all the existing DEs. I have about 1000 of them now. We are already test running the app and have used it in field to capture data. Thanks goodness its just test run.

May I know pls, does it matter if the first letter is capital or small?

1 Like