Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Highlighted
bentotdecruz2
New Contributor II

Use calculated dimension in hypercubedef

May I know how to send a calculated dimension in qlik config?

Usually, when sending the config to engine, we put the field name under qFieldDefs.  In below code, it's SOMEFIELD.

 

{
	"handle": 1,
	"method": "CreateSessionObject",
	"params": {
		"qProp": {
			"qInfo": {
				"qId": "",
				"qType": "HyperCube"
			},
			"qHyperCubeDef": {
				"qDimensions": [
					{
						"qNullSuppression": false,
						"qDef": {
							"qFieldDefs": [
								"SOMEFIELD"
							]
						}
					}
				],
				"qMeasures": [],
				"qInitialDataFetch": [
					{
						"qHeight": 10000,
						"qWidth": 1
					}
				]
			}
		}
	}
}

However, I want to pass a calculated dimension, like the following:

AGGR(DISTINCT Rank(FIELD1,4,1),FIELD2)

I really don't have any idea where to put a calculated dimension.  Please advise.

 

Labels (2)
6 Replies
Employee
Employee

Re: Use calculated dimension in hypercubedef

It should be sufficient to add a '=' character to the beginning of the string used for the qFieldDefs property. So instead of "SOMEFIELD" you could write

=AGGR(DISTINCT Rank(FIELD1,4,1),FIELD2)

 

bentotdecruz2
New Contributor II

Re: Use calculated dimension in hypercubedef

My question is actually where to put that calculated dimension inside the config.
Employee
Employee

Re: Use calculated dimension in hypercubedef

Oh... Just put it right in the "qFieldDefs" list just like you did for "SOMEFIELD".
bentotdecruz2
New Contributor II

Re: Use calculated dimension in hypercubedef

it doesn't work
Employee
Employee

Re: Use calculated dimension in hypercubedef

Hmm... It should. What kind of error are you getting? I added a calculated dimension to the following example that illustrates how to use hypercubes in the .Net SDK:

https://github.com/kolsrud/qlik-dot-net-sdk-hypercube-usage/blob/master/HypercubeUsage/Program.cs#L1...

That example produces a hypercube that is defined like this:

 

"qHyperCubeDef": {
... "qDimensions": [ {
... "qDef": { "qFieldDefs": [ "=Year(TimeStamp)&'-'&Month(TimeStamp)" ],
... } } ], "qMeasures": [ {
... "qDef": {
... "qDef": "Sum([Sales Amount])" } } ] }

 

 

bentotdecruz2
New Contributor II

Re: Use calculated dimension in hypercubedef

Sorry, you're right. It works. I think I might have forgotten to put the '=' sign or create the necessary variable. Thanks a lot.