A slice is a definition of the subset of data from your data source that will be shown in your report when you open it. By using slices in a report you can easily switch between different sets of values. To see different examples of slice configuration, visit our Examples page.
Read more in the following sections:
You can define fields that go to rows, go to columns, go to measures, add filtering, sorting, report filtering, expands, and drills. Here is a list of all available properties for a slice
:
columns
– Array of objects. A list of hierarchies selected in the report slice for columns. Each object can have the following properties: uniqueName
– String. The hierarchy’s unique name.caption
(optional) – String. The hierarchy’s caption.dimensionName
(optional) – String. The dimension name.filter
(optional) – Filter Object. Contains filtering information.levelName
(optional) – String. Used to specify the level of the hierarchy that is shown on the grid or on the chart.showTotals
(optional) — Boolean. Defines whether totals are shown or hidden for the hierarchy. When set to true
, totals are shown. Only for the classic view.showTotals
is not specified, totals’ visibility is defined by the options.showTotals
property. Learn more about options.showTotals.sort
(optional) – String. The sorting type for members ("asc"
, "desc"
or "unsorted"
).sortOrder
(optional) – Array of strings. Set custom ordering for hierarchy members. Only for "csv"
and "json"
data source types. sortOrder
can be specified like this: ["member_1", "member_2", etc.]
. drills
(optional) – Object. Contains drill-down information in multilevel hierarchies. drillAll
(optional) – Boolean. Indicates whether all levels of all hierarchies in the slice will be drilled down (true
) or drilled up (false
).columns
(optional) – Array of objects. Used to save and restore drilled down columns.rows
(optional) – Array of objects. Used to save and restore drilled down rows. drillThrough
(optional) – Array of strings. Allows pre-defining the slice for the drill-through view. Only for "csv"
, "json"
, and "api"
data source types. drillThrough
can be specified like this: ["Hierarchy name 1", "Hierarchy name 2", etc.]
(see live demo).expands
(optional) – Object. Stores information about the expansion of nodes. expandAll
(optional) – Boolean. Indicates whether all nodes in the data tree will be expanded (true
) or collapsed (false
) on the grid and on the charts.columns
(optional) – Array of objects. Used to save and restore expanded columns.rows
(optional) – Array of objects. Used to save and restore expanded rows. flatSort
– Array of objects. Only for "json"
, "csv"
, and "api"
data source types. It contains the list of objects defining the multicolumn sorting on the flat grid. Each object has the following properties:uniqueName
– String. The unique name of the hierarchy being sorted.sort
– String. The sorting type ("asc"
, "desc"
, or "undefined"
).Ctrl+click
.measures
– Array of objects. A list of the selected measures and those which have non-default properties. Each object has these properties: uniqueName
– String. The measure’s unique name.active
(optional) – Boolean. Indicates whether the measure will be selected for the report (true
) or not (false
). active: false
can be useful if the measure has non-default properties, but should not be selected for the grid or the chart.aggregation
(optional) — String. The name of the aggregation that will be applied to the measure. To see the list of supported aggregation functions for each data source type, refer to Flexmonster’s technical specifications. If the measure is calculated, aggregation
will be set to "none"
.availableAggregations
(optional) — Array of strings. Note that starting from version 2.8, the availableAggregations
property is considered deprecated. Use the Mapping’s aggregations
property instead.availableAggregations
represents the list of aggregation functions that can be applied to the current measure. If the measure is calculated, availableAggregations
will be set to []
.caption
(optional) – String. The measure’s caption.formula
(optional) – String. Represents the formula. Refers to the calculated measure. It can contain the following operators: +
, -
, *
, /
. Other measures can be referenced using the measure’s unique name and the associated aggregation function, for example sum("Price")
or max("Order")
. To see the list of supported aggregation functions for each data source type, refer to Flexmonster’s technical specifications. individual
(optional) – Boolean. Refers to the calculated measure. Defines whether the formula is calculated using raw values (true
) or using aggregated values (false
). Only for "json"
and "csv"
data source types. Default value: false
.
calculateNaN
(optional) – Boolean. Refers to the calculated measure. Defines whether the formula is calculated using NaN values (true
) or using null values (false
). Default value: true
.format
(optional) – String. The name of the number formatting that will be applied to the measure. Measure values can be formatted according to the number formatting defined in the report. All available number formattings are stored in the formats
array in the report. More information about the number formatting part of the report can be found in the number formatting article.grandTotalCaption
(optional) – String. The measure’s grand total caption.flatOrder
– Array of strings. Defines the order of the hierarchies for the "flat"
grid type. flatOrder
can be specified like this: ["Hierarchy name 1", "Hierarchy name 2", etc.]
(see live demo). Only for "json"
, "csv"
, and "api"
data source types.memberProperties
– Array of objects. Only for "microsoft analysis services"
and "mondrian"
data source types. Each object in the array has the following properties: levelName
– String. The hierarchy’s unique name.properties
– Array of strings. Represents the properties to be shown on the grid. Other available member properties can be accessed through the context menu. reportFilters
– Array of objects. A list of hierarchies selected in the report slice for report filters. Each object has the following properties:uniqueName
– String. The hierarchy’s unique name.caption
(optional) – String. The hierarchy’s caption.dimensionName
(optional) – String. The dimension name.filter
(optional) – Filter Object. Contains filtering information.levelName
(optional) – String. Used to specify the level of the hierarchy that is shown on the grid or on the chart.sort
(optional) – String. The sorting type for members ("asc"
, "desc"
or "unsorted"
).sortOrder
(optional) – Array of strings. Set custom ordering for hierarchy members. Only for "csv"
and "json"
data source types. sortOrder
can be specified like this: ["member_1", "member_2", etc.]
. rows
– Array of objects. A list of hierarchies selected in the report slice for rows. Each object can have the following properties: uniqueName
– String. The hierarchy’s unique name.caption
(optional) – String. The hierarchy caption.dimensionName
(optional) – String. The dimension name.filter
(optional) – Filter Object. Contains filtering information.levelName
(optional) – String. Used to specify the level of the hierarchy that is shown on the grid or on the chart.showTotals
(optional) — Boolean. Defines whether totals are shown or hidden for the hierarchy. When set to true
, totals are shown. Only for the classic view.showTotals
is not specified, totals’ visibility is defined by the options.showTotals
property. Learn more about options.showTotals.sort
(optional) – String. The sorting type for members ("asc"
, "desc"
or "unsorted"
).sortOrder
(optional) – Array of strings. Set custom ordering for hierarchy members. Only for "csv"
and "json"
data source types. sortOrder
can be specified like this: ["member_1", "member_2", etc.]
. sorting
(optional) – Object. Defines the sorting for numbers in a specific row and/or column in the pivot table. column
– Object. Defines the sorting for numbers in a specific column. This object has 3 properties: tuple
– Array of strings. Consists of unique names that identify the column in the table based on the column’s data.measure
– Object. Identifies the measure on which sorting will be applied. Has the following properties: uniqueName
– String. The measure’s unique name.aggregation
(optional) – String. The measure’s aggregation type. type
– String. The sorting type ("asc"
or "desc"
). row
– Object. Defines the sorting for numbers in a specific row. This object has 3 properties: tuple
– Array of strings. Consists of unique names that identify the row in the table based on the row’s data.measure
– Object. Identifies the measure on which sorting will be applied. Has the following properties: uniqueName
– String. The measure’s unique name.aggregation
(optional) – String. The measure’s aggregation type. type
– String. The sorting type ("asc"
or "desc"
). If a slice was not defined, Flexmonster will select a default slice for the report, where the first hierarchy from the data goes to rows and the first measure goes to columns. The automatic default slice selection is available for JSON and CSV data sources (it is not available for OLAP). You can turn off the default slice by setting showDefaultSlice
in options
to false
. For example, take a look at the JSON data below:
var jsonData = [
{
"Category": "Accessories",
"Price": 125,
"Quantity": 100
},
{
"Category": "Accessories",
"Price": 74,
"Quantity": 235
},
{
"Category": "Bikes",
"Price": 233,
"Quantity": 184
}
]
"Category"
is the first hierarchy, so it goes to rows
. "Price"
is the first measure, so it goes to columns
. For this dataset, the default slice will look like this:
{
"dataSource": {
"data": jsonData
},
"slice": {
"rows": [
{
"uniqueName": "Category"
}
],
"columns": [
{
"uniqueName": "[Measures]"
}
],
"measures": [
{
"uniqueName": "Price"
}
]
}
}
See the same example with a default slice on JSFiddle.
Starting from version 2.304, a slice
can be defined with only measures
:
{
"dataSource": {
"filename": "https://www.flexmonster.com/download/data.csv"
},
"slice": {
"measures": [
{
"uniqueName": "Price",
"aggregation": "sum",
"active": true
}
]
}
}
Open on JSFiddle.
"uniqueName": "[Measures]"
allows you to define where the measures will be displayed (in rows
or in columns
). By default they go to columns
. Here is an example of a slice
with rows
, columns
, and measures
:
{
"dataSource": {
"filename": "https://www.flexmonster.com/download/data.csv"
},
"slice": {
"rows": [
{
"uniqueName": "Category",
"filter": {
"members": [
"category.[cars]",
"category.[bikes]"
]
},
"sort": "desc"
}
],
"columns": [
{
"uniqueName": "[Measures]"
},
{
"uniqueName": "Color",
"filter": {
"members": [
"color.[blue]"
]
}
}
],
"measures": [
{
"uniqueName": "Price",
"aggregation": "sum",
"active": true
},
{
"uniqueName": "Discount",
"aggregation": "min",
"active": true
}
]
}
}
See the same example on JSFiddle.
A report filter allows you to display different data subsets in the report. In Flexmonster Pivot the reportFilters
property is used for defining the report filters as follows:
{
"dataSource": {
"filename": "https://www.flexmonster.com/download/data.csv"
},
"slice": {
"reportFilters": [
{
"uniqueName": "Color",
"filter": {
"members": [
"color.[yellow]",
"color.[white]"
]
}
}
],
"rows": [
{
"uniqueName": "Category"
}
],
"columns": [
{
"uniqueName": "[Measures]"
}
],
"measures": [
{
"uniqueName": "Price"
}
]
}
}
See an example with a report filter on JSFiddle.
The sorting object defines the sorting for numbers in a specific row and/or column in the pivot table. Sorting is usually configured on the grid and then saved within the report. It looks like this:
"sorting": {
"column": {
"type": "desc",
"tuple": [],
"measure": "Price"
}
}
Sorting for members of columns and rows is defined like this:
"rows": [
{
"uniqueName": "Category",
"filter": {
"members": [
"category.[cars]",
"category.[bikes]"
]
},
"sort": "desc"
}
]
Information about expands and collapses is stored within the slice
. When a customer performs one of these operations, all the changes can be saved within the report. Use the expandAll
property to apply the operation to all levels of data detail at once. This is how an expands
object looks:
"expands": {
"expandAll": false,
"rows": [
{
"tuple": [
"category.[accessories]"
]
},
{
"tuple": [
"category.[cars]"
]
}
]
}
The drills
object is used to store information about drill-downs in multilevel hierarchies. Here is an example of a drills
object:
"drills": {
"drillAll": false,
"rows": [
{
"tuple": [
"category.[accessories]"
]
},
{
"tuple": [
"category.[accessories].[bike racks]"
]
},
{
"tuple": [
"category.[accessories].[bottles and cages]"
]
}
]
}
You can create as many calculated measures for one report as you need. When you save the report all the calculated measures will be saved as well and loaded when the report is retrieved. Note that you can add calculated measures only for reports that are based on a "csv"
, "json"
, or "api"
data source type. Below is an example of a calculated measure:
"measures": [
{
"uniqueName": "Avg",
"formula": "sum('Price') / count('Category') ",
"caption": "Avg",
"active": true
}
]
Use the Field List to define report filters, rows, columns, and values at run time.
Sorting, filtering, drill-ups, drill-downs, and expand/collapse operations are available directly on the grid and on built-in pivot charts.
You can change the slice along with other report parts using the API call setReport(). To change only the slice use the runQuery() call.