2 Replies Latest reply: Aug 6, 2018 8:14 AM by Jesper Snihs RSS

    Pivot table with visualization API

    Jesper Snihs

      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

          • Re: Pivot table with visualization API
            Jesper Snihs

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