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

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

@jetisco4u it does not matter. The first character must be a letter (A-Za-z) only.

1 Like

Thanks @jason

Meanwhile I am trying to use the Import/Export app to delete all existing metadata and reupload new file. I am done with the organisationunit file and I was trying to import it and use it to delete existing record. But I was getting the error “No matching object for given reference. Identifier was UID, and object was …”

How can I delete the existing record to upload new ones.

Finally all my indicators are not showing errors again. Thanks to all contributors.

1 Like