Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
master_t
Partner - Creator II
Partner - Creator II

Having two Hypercubes with the same data

Hi everyone

The extension I'm building needs to access the SAME data, but I need to access this data in two forms: one as a STRAIGHT hypercube and one as a PIVOT hypercube.


So basically, I want to have access to TWO hypercubes within in my paint function: one with qMode = "P" and one with qMode = "S".

I managed to define two hypercubes in my properties like this:

initialProperties : {

        qHyperCubeDef: {

            qDimensions: [],

            qMeasures: [],

            qInitialDataFetch: [{

                qWidth: 50,

                qHeight: 50

          }]

        },

    pivotCube: {

        qHyperCubeDef: {

            qDimensions: [],

            qMeasures: [],

            qMode: "P",

            qInitialDataFetch: [{

                qWidth: 50,

                qHeight: 50

            }]

        }

    }

},

definition : {

    type : "items",

    component : "accordion",

    items : {

        dimensions : {

            uses : "dimensions",

            qNullSuppression: false,

            min : 1,

        },

        measures : {

            uses : "measures",

            min : 1,

        },

        sorting : {

            uses : "sorting"

        },

        settings : {

            uses : "settings",

            items : {

                initFetchRows : {

                    ref : "qHyperCubeDef.qInitialDataFetch.0.qHeight",

                    label : "Initial fetch rows",

                    type : "number",

                    defaultValue : 50

                }

            }

        }

    }

}

however, the problem is that I don't know how to "synchronize" the two cubes. Let me explain: adding the "measures" and "dimensions" items in the definition, like I did above, triggers some mechanism where the DEFAULT cube is automatically updated when the user changes the dimensions and measures in the UI. However, these changes are not reflected in my second cube ("pivotCube"), which is always EMPTY.

How do I apply the measures and dimensions to the second hypercube as well, so I have them both synchronized in my paint function?

1 Solution

Accepted Solutions
ErikWetterberg

Hi,

You could compare DimensionInfo and MeasureInfo for the two cubes or you could use getProperties to get the actual properties.

You're right, the backend API won't help you with the second cube, you would need to access the layout directly and possibly use enigmajs for function calls.

Erik Wetterberg

View solution in original post

3 Replies
ErikWetterberg

Hi,

looks complicated...

What you could do is check that they are qual in paint, and call applyPatches if they are not. This will trigger an update, recalculation and a new call to paint.

Be careful, or you will be building an inifinite loop. Also try to make all changes in one call.

Erik Wetterberg

Please as Correct and/ or Helpful is this helps you.

master_t
Partner - Creator II
Partner - Creator II
Author

Hi Erik, thanks for your reply.

I was already trying to use patching, but I have a question. You say:

check that they are qual in paint, and call applyPatches if they are not.

how do I do this? I don't see any methods in the backend API that let me read the Hypercubes' definition object, so how can I compare their definitions to see if they match?


Also, the backend API doesn't let me chose which cube to use for methods like "getDataPages" or "getPivotData", it always calls them using the default hypercube, so how would I manually retrieve the data from the second cube?

ErikWetterberg

Hi,

You could compare DimensionInfo and MeasureInfo for the two cubes or you could use getProperties to get the actual properties.

You're right, the backend API won't help you with the second cube, you would need to access the layout directly and possibly use enigmajs for function calls.

Erik Wetterberg