Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Øystein_Kolsrud
Employee
Employee

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)

 

Anonymous
Not applicable
Author

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

Oh... Just put it right in the "qFieldDefs" list just like you did for "SOMEFIELD".
Anonymous
Not applicable
Author

it doesn't work
Øystein_Kolsrud
Employee
Employee

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])" } } ] }

 

 

Anonymous
Not applicable
Author

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