Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
sama007
Contributor
Contributor

Find in an expression the fields/dimensions/variables used?

Hello,

how to find in an expression the fields/dimensions etc ... used?

For example if I have the following expression

If(my_var = 0, my_field_1, my_field_2)

I want to know that this expression contains one variable (my_var) and two fields (my_field_1, my_field_2).

Is it possible to do this with qlick sense engine api (without necessarily using regexp) ?

Labels (2)
1 Reply
ckg
Employee
Employee

You can use the GetFieldsFromExpression method to get the field names from an expression. I am not aware of a way to get the variable names, however if I was doing something like this I would use the CreateSessionObject with the following parameters:

    {
      qInfo: {
        qType: 'VariableList',
      },
      qVariableListDef: {
        qType: 'variable',
        qShowReserved: false,
        qShowConfig: false,
      },
    }


and then use GetLayout  on the resulting session object to get a list of all the variables in your app which could then be used with some sort of regex function to figure out which variables are being used in the expression.