Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

jesper_snihs
Contributor

Pivot table with visualization API

Is there any way that I can get the second dimension to be in the column section per default with the visualization API for the pivot-table component so it looks like this?

Skärmklipp.PNG

Because using the following code is only stacking the dimensions in the rows:

app.visualization.create(

                  'pivot-table',

                  [

                    {

                      "qDef": {

                        "qFieldDefs": [

                          "Dim1"

                        ],

                        "qFieldLabels": [

                          "Dim1"

                        ]

                      },

                      "qNullSuppression": true

                    },

                    {

                      "qDef": {

                        "qFieldDefs": [

                          "Dim2"

                        ],

                        "qFieldLabels": [

                          "Dim2"

                        ]

                      },

                      "qNullSuppression": true

                    },

                    {

                      "qDef": {

                        "qLabel": "Count(Dim3)",

                        "qDef": "Count(Dim3)",

                        "qNumFormat": {

                          "qType": "F",

                          "qnDec": 0,

                          "qUseThou": 0,

                          "qFmt": "# ##0",

                          "qDec": ".",

                          "qThou": ","

                        }

                      }

                    }

                  ],

                  {

                    "showTitles": true,

                    "title": "Pivot Table"

                  }

                ).then(function(vis){

                    vis.show("QV01");

                });

Skärmklipp2.PNG

1 Solution

Accepted Solutions
erik_wetterberg
Honored Contributor

Re: Pivot table with visualization API

Hi,

You should be able to set qNoOfLeftDims as described in the Engine API:

https://help.qlik.com/en-US/sense-developer/June2018/apis/EngineAPI/definitions-HyperCubeDef.html

Erik Wetterberg

http://extendingqlik.upper88.com/

Erik Wetterberg
https://extendingqlik.upper88.com/
2 Replies
erik_wetterberg
Honored Contributor

Re: Pivot table with visualization API

Hi,

You should be able to set qNoOfLeftDims as described in the Engine API:

https://help.qlik.com/en-US/sense-developer/June2018/apis/EngineAPI/definitions-HyperCubeDef.html

Erik Wetterberg

http://extendingqlik.upper88.com/

Erik Wetterberg
https://extendingqlik.upper88.com/
jesper_snihs
Contributor

Re: Pivot table with visualization API

Hi Erik,

Yes, that worked! Thank you!

If anyone is interested in what changes I did it is in the options where I added the "qHyperCubeDef":

app.visualization.create(

                  'pivot-table',

                  [

                    {

                      "qDef": {

                        "qFieldDefs": [

                          "Dim1"

                        ],

                        "qFieldLabels": [

                          "Dim1"

                        ]

                      },

                      "qNullSuppression": true

                    },

                    {

                      "qDef": {

                        "qFieldDefs": [

                          "Dim2"

                        ],

                        "qFieldLabels": [

                          "Dim2"

                        ]

                      },

                      "qNullSuppression": true

                    },

                    {

                      "qDef": {

                        "qLabel": "Count(Dim3)",

                        "qDef": "Count(Dim3)",

                        "qNumFormat": {

                          "qType": "F",

                          "qnDec": 0,

                          "qUseThou": 0,

                          "qFmt": "# ##0",

                          "qDec": ".",

                          "qThou": ","

                        }

                      }

                    }

                  ],

                  {

                    "qHyperCubeDef":{

                         "qNoOfLeftDims": 1

                    },

                    "showTitles": true,

                    "title": "Pivot Table"

                  }

                ).then(function(vis){

                    vis.show("QV01");

                });

Community Browser