6 Replies Latest reply: Apr 27, 2017 5:32 PM by Bernd Podhradsky RSS

    Total Cells via GetData

    Bernd Podhradsky

      Hey there!

       

      I'm using the GetData() function of a table visualization to grab its data; headers are returned perfectly fine, so are the actual data rows. However, despite the fact that the visualization does have auto totals, the returned matrix does not contain these (the matrix simply doesn't contain that row).

       

      How can I fetch a matrix from the object that actually includes a complete matrix?

       

      Thanks in advance,

      Bernd

        • Re: Total Cells via GetData
          Øystein Kolsrud

          I think you'll find the totals-row in this property of the hypercube layout:

           

          HyperCube.GrandTotalRow Property

           

          So you don't use GetData to access that information. You should instead do GetLayout on the visualization and grab the data from there.

            • Re: Total Cells via GetData
              Bernd Podhradsky

              Hi!

               

              Thank you very much. Maybe I misunderstood your answer, but how can I actually grab data with GetLayout()? The ITableLayout interface, for instance, does not contain methods to actually grab the data of the table, it seems to just contain the settings that define the layout.

               

              Could you provide me a small code example that shows how you could grab a table matrix that represents what is actually displayed to the user (including total row)?

               

              Thanks,

              Bernd

                • Re: Total Cells via GetData
                  Øystein Kolsrud

                  You are right that the ITableLayout interface does not provide methods for grabbing data, but the totals row is not grabbed the way the other data is grabbed. Instead you'll find it directly in the layout structure. The ITableLayout interface contains a hypercube that in turn contains that totals-row directly in the layout structure. To access it you would do something like this:

                   

                  var tableLayout = table.GetLayout.As<TableLayout>();
                  var totalsRow = tableLayout.HyperCube.GrandTotalRow;
                  

                   

                  Also, the properties of the layout structure are accessible directly from the table object through properties that work as shortcuts into the layout. And the properties of the hypercube are them selves expanded, so the GrandTotalRow is directly accessible from the table object through this property: ITable.GrandTotalRow Property That means you could simplify the above code to this:

                   

                  var totalsRow = table.GrandTotalRow
                  

                   

                  Those short cuts are quite convenient in cases like this (which is why they are there in the first place), but they can also be rather confusing which is why I often recommend the first solution.

                   

                  So the full solution you are looking for would be to concatenate that row with the data you get through the "GetData" method.

                    • Re: Total Cells via GetData
                      Bernd Podhradsky

                      Hi!

                       

                      That totally makes sense now, thanks again.

                       

                      Just a quick additional question: in a PivotTable, there will be more totals than just the "grand total" - will they be returned when using "GetData" or how can they be accessed?

                       

                      Bernd

                        • Re: Total Cells via GetData
                          Øystein Kolsrud

                          I'm no expert on pivot tables, so someone else might give a better answer, but it doesn't look to me like pivot table hypercubes differ from straight hypercubes with regards to this.

                            • Re: Total Cells via GetData
                              Bernd Podhradsky

                              Hi!

                               

                              Thanks again for taking care of my issue. I find the API documentation to pretty ridiculous in these terms; never worked with a worse documentation in my life, to be quite honest.

                               

                              I'm still stuck with my issue and it is business critical for us - do you know who to contact best to get support for API issues like these (we are a partner of Qlik). Opening a support case doesn't allow me to choose a category that fits "API Troubles" at all.

                               

                              BTW: The problem is still have is: the GrandTotalRow gives me a list of cells - but not the exact same number as cells as all the others rows have (because not all columns do have totals). However, there's no property that allows me to find out to which actual columns the total columns belong. Also, even though a total is being displayed for that particular table, the Position property of the Totals property says "NoTotals" .

                               

                              Thanks in advance,

                              Bernd