MasterScript
MasterScript copied to clipboard
Unable to use functions in _MasterItemExpression*
I tried to implement Master Items based on calculated fields, e.g. year(TIMESTAMP_FIELD)
, but result is always the same and that expression in enclosed by square brackets: [year(TIMESTAMP_FIELD)]
.
Various encapsulations produce similar non-functional expressions:
["=year(TIMESTAMP_FIELD)"]
=["year(TIMESTAMP_FIELD)"]
I have this same issue with calculated dimensions. If begin the expression in excel with '= so it doesn't try to evaluate it mostly works. However the Dimension name shows up as the expression not the _MasterItemName in some charts. If the go in to edit the master dimension in the Qlik UI and save the name shows correctly. However then it seems to "break" from the MasterItems logic and on subsequent "Import Master Items" will create a new calculated dimension rather than updating the existing.
i will look at this and change the way it constructs the field in a future version.
@BenMyers-DISqr @comadot Just for reference. In excel, you can set the cell type to 'text' so that Excel ignores the equal signs. That works well (see image below) but MasterScript still has issues creating the dimension with an expression as label or definition, in qlik sense, it's still wrapped inside quotes.
This is a well-formed javascript object:
The only workaround I can think of is to not use the model methods (createDimension()
etc...) inside qlik but talking directly to the socket by sending it the entire rpc json object. But hopefully @AnalyticsEarth has an easier solution.
ps. to simplify the excel table, especially in regards to hierarchies, I'm only using a single column for defining definitions and labels, The user needs to input the expressions between commas if there are several, and in the script you can parse them into an array:
...
, "qFieldDefs": input.fieldsdef.split(/[,] ?/) || data.fieldsdef
, "qFieldLabels": input.fieldslabel.split(/[,] ?/) || data.fieldslabel
...