Skip to main content
Skip table of contents

Dense and Sparse Cubes

By default, the /table endpoint returns a "dense cube". That means that it returns every value, even if the value is null or 0.

If you are generating large table queries that are likely to contain lots of null or 0 values, you can instead access the /table/sparse endpoint. This returns only non zero and non null values. Each returned value has an index associated with it, which you can use to identify where it belongs in the table.

The only difference between the two endpoints is the contents of the cubes section in the response. They both accept identical input and return otherwise identical responses.

Example

Consider the following table, showing Gender by Marital Status:

As you can see, it contains a number of cells with 0 values.

To query the Open Data API for these values, you would use a request similar to the following:

CODE
{
    "database": "str:database:bank",
    "measures": [
        "str:count:bank:F_Customer"
    ],
    "dimensions": [
        [
            "str:field:bank:F_Customer:Gender"
        ],
        [
            "str:field:bank:F_Customer:Marital_Status"
        ]
    ]
}

Below are the examples of the cubes section in the responses from the two endpoints:

/table:

CODE
"cubes": {
    "str:count:bank:F_Customer": {
      "values": [
        [
          59144,
          30323,
          98,
          26672,
          0
        ],
        [
          53967,
          43405,
          112,
          16317,
          0
        ],
        [
          10,
          8,
          0,
          7,
          0
        ],
        [
          0,
          0,
          0,
          0,
          39129
        ]
      ],
      "precision": 0
    }
  }

/table/sparse:

CODE
  "cubes": {
    "str:count:bank:F_Customer": {
      "values": {
        "0": {
          "value": 59144
        },
        "1": {
          "value": 30323
        },
        "2": {
          "value": 98
        },
        "3": {
          "value": 26672
        },
        "5": {
          "value": 53967
        },
        "6": {
          "value": 43405
        },
        "7": {
          "value": 112
        },
        "8": {
          "value": 16317
        },
        "10": {
          "value": 10
        },
        "11": {
          "value": 8
        },
        "13": {
          "value": 7
        },
        "19": {
          "value": 39129
        }
      },
      "precision": 0
    }
  }
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.