Row and column filter not working

Answered

I am using your example https://codepen.io/webdatarocks/pen/arEYLM and modified JS code as below. I observe that Row and Column filters do not work. Please let me know if I am making any mistake.
 
var pivot = new WebDataRocks({
container: “#wdr-component”,
toolbar: true,
height: 530,
customizeCell: customizeCellFunction,
beforetoolbarcreated: customizeToolbar,
report: {

dataSource: { data: getData() },
options: { grid: { type: “classic”, title: “A New Title” } },

“formats”: [
{“name”: “aa”, “decimalPlaces”:1, “currencySymbol”:”R”},
{
“name”: “”,
“thousandsSeparator”: ” “,
“decimalSeparator”: “.”,
//”decimalPlaces”: 2,
“maxSymbols”: 20,
“currencySymbol”: “”,
“currencySymbolAlign”: “left”,
“nullValue”: ” “,
“infinityValue”: “Infinity”,
“divideByZeroValue”: “Infinity”
}
],
“slice”: {
“reportFilters”: [ { “uniqueName”: “Country”, “filter”: { “members”: [ “Country.[France]” ] } } ],
“rows”: [
{
“uniqueName”: “Date.Year”
},
{
“uniqueName”: “Date.Month”,
“filter”: { “members”: [ “Date.Month.[May]” ] }
},
{
“uniqueName”: “Date.Day”
}
],
“columns”: [
{
“uniqueName”: “Country”,
“filter”: { “members”: [ “Country.[France]” ] }
},
{
“uniqueName”: “Measures”
},
],
“measures”: [
{
“uniqueName”: “Revenue”,
“aggregation”: “sum”,
“caption”: “Revenue”,
“format”: “currency”
},
{
“uniqueName”: “Revenue Percentage”,
“formula”: “sum(\”Revenue\”) “,
“aggregation”: “percentofrow”,
//”individual”: true,
“caption”: “Revenue”,
“format”: “aa”,
“grandTotalCaption”:”ooo”
},
]
},
“conditions”: [
{
“formula”: “#value > 1000000”,
“measure”: “Revenue”,
“format”: {
“backgroundColor”: “#0598df”,
“color”: “#FFFFFF”,
“fontFamily”: “Arial”,
“fontSize”: “20px”
}
},
{
“formula”: “#value > 25”,
“measure”: “Revenue Percentage”,
“format”: {
“backgroundColor”: “#f45328”,
“color”: “#FFFFFF”,
“fontFamily”: “Arial”,
“fontSize”: “12px”
}
},
],
}
});
function customizeCellFunction(cell, data) {
//if( data.isClassicTotalRow) alert(“Yes”);
if (data.type == “value” && !data.isDrillThrough && data.isGrandTotalColumn) {
if (data.value < 200000) {
cell.text = “<img src=’https://static.webdatarocks.com/uploads/2019/02/21213347/icons8-decline-64-1.png’ class=’centered’>”;
} else if (data.value >= 200000) {
cell.text = “<img src=’https://static.webdatarocks.com/uploads/2019/02/21213348/icons8-account-64.png’ class=’centered’>”;
}
}
}
function customizeToolbar(toolbar) {
var tabs = toolbar.getTabs(); // get all tabs from the toolbar
toolbar.getTabs = function () {
delete tabs[0]; // delete the first tab
return tabs;
}
}
function getData() {
return [
{
“Country”: “Spain”,
“Revenue”: 33297,
“Date”: “2018-02-21T08:05:23.683Z”
},
{
“Country”: “France”,
“Revenue”: 232333,
“Date”: “2018-02-21T08:05:23.683Z”
},
{
“Country”: “France”,
“Revenue”: 66233,
“Date”: “2018-03-21T08:05:23.683Z”
},
{
“Country”: “Spain”,
“Revenue”: 27356,
“Date”: “2018-03-02T18:57:56.640Z”
},
{
“Country”: “France”,
“Revenue”: 39577,
“Date”: “2018-04-08T00:12:37.523Z”
},
{
“Country”: “Spain”,
“Revenue”: 50000,
“Date”: “2019-04-08T00:12:37.523Z”
},
{
“Country”: “France”,
“Revenue”: 43504,
“Date”: “2018-05-23T04:40:40.868Z”
},
{
“Country”: “Spain”,
“Revenue”: 44504,
“Date”: “2018-05-23T04:40:40.868Z”
},
{
“Country”: “France”,
“Revenue”: 23231,
“Date”: “2018-06-23T04:40:40.868Z”
},
{
“Country”: “Spain”,
“Revenue”: 65000,
“Date”: “2018-06-23T04:40:40.868Z”
},
{
“Country”: “France”,
“Revenue”: 87878,
“Date”: “2018-07-23T04:40:40.868Z”
},
{
“Country”: “Spain”,
“Revenue”: 33878,
“Date”: “2018-07-23T04:40:40.868Z”
},
{
“Country”: “France”,
“Revenue”: 95678,
“Date”: “2018-08-23T04:40:40.868Z”
},
{
“Country”: “Spain”,
“Revenue”: 12878,
“Date”: “2018-08-23T04:40:40.868Z”
},
{
“Country”: “France”,
“Revenue”: 12221,
“Date”: “2018-09-23T04:40:40.868Z”
},
{
“Country”: “Spain”,
“Revenue”: 22221,
“Date”: “2018-09-23T04:40:40.868Z”
},
{
“Country”: “Spain”,
“Revenue”: 87878,
“Date”: “2018-10-23T04:40:40.868Z”
},
{
“Country”: “France”,
“Revenue”: 75978,
“Date”: “2018-10-23T04:40:40.868Z”
},
{
“Country”: “Spain”,
“Revenue”: 23452,
“Date”: “2018-11-23T04:40:40.868Z”
},
{
“Country”: “France”,
“Revenue”: 43452,
“Date”: “2018-11-23T04:40:40.868Z”
},
{
“Country”: “France”,
“Revenue”: 66452,
“Date”: “2018-12-23T04:40:40.868Z”
},
{
“Country”: “Spain”,
“Revenue”: 34452,
“Date”: “2018-12-23T04:40:40.868Z”
},
// Hello
{
“Country”: “Norway”,
“Revenue”: 883297,
“Date”: “2018-02-21T08:05:23.683Z”
},
{
“Country”: “Sweden”,
“Revenue”: 21333,
“Date”: “2018-02-21T08:05:23.683Z”
},
{
“Country”: “Sweden”,
“Revenue”: 6633,
“Date”: “2018-03-21T08:05:23.683Z”
},
{
“Country”: “Norway”,
“Revenue”: 217356,
“Date”: “2018-03-02T18:57:56.640Z”
},
{
“Country”: “Sweden”,
“Revenue”: 64577,
“Date”: “2018-04-08T00:12:37.523Z”
},
{
“Country”: “Norway”,
“Revenue”: 54000,
“Date”: “2018-04-08T00:12:37.523Z”
},
{
“Country”: “Sweden”,
“Revenue”: 12504,
“Date”: “2018-05-23T04:40:40.868Z”
},
{
“Country”: “Norway”,
“Revenue”: 33504,
“Date”: “2018-05-23T04:40:40.868Z”
},
{
“Country”: “Sweden”,
“Revenue”: 87231,
“Date”: “2018-06-23T04:40:40.868Z”
},
{
“Country”: “Norway”,
“Revenue”: 31000,
“Date”: “2018-06-23T04:40:40.868Z”
},
{
“Country”: “Sweden”,
“Revenue”: 91878,
“Date”: “2018-07-23T04:40:40.868Z”
},
{
“Country”: “Norway”,
“Revenue”: 71878,
“Date”: “2018-07-23T04:40:40.868Z”
},
{
“Country”: “Sweden”,
“Revenue”: 51678,
“Date”: “2018-08-23T04:40:40.868Z”
},
{
“Country”: “Norway”,
“Revenue”: 56878,
“Date”: “2018-08-23T04:40:40.868Z”
},
{
“Country”: “Sweden”,
“Revenue”: 45221,
“Date”: “2018-09-23T04:40:40.868Z”
},
{
“Country”: “Norway”,
“Revenue”: 35221,
“Date”: “2018-09-23T04:40:40.868Z”
},
{
“Country”: “Norway”,
“Revenue”: 98878,
“Date”: “2018-10-23T04:40:40.868Z”
},
{
“Country”: “Sweden”,
“Revenue”: 1278,
“Date”: “2018-10-23T04:40:40.868Z”
},
{
“Country”: “Norway”,
“Revenue”: 66652,
“Date”: “2018-11-23T04:40:40.868Z”
},
{
“Country”: “Sweden”,
“Revenue”: 33662,
“Date”: “2018-11-23T04:40:40.868Z”
},
{
“Country”: “Sweden”,
“Revenue”: 16452,
“Date”: “2018-12-23T04:40:40.868Z”
},
{
“Country”: “Norway”,
“Revenue”: 34902,
“Date”: “2018-12-23T04:40:40.868Z”
}
]
}

1 answer

WebDataRocks Team WebDataRocks April 28, 2020

Hello,
 
Thank you for your question.
 
Our team has modified the code you have provided in the way filters work correctly.
You are welcome to check it out by the link.
 
We would like to provide some additional explanations about the way filters should be defined:

  1. There is no need to wrap the particular member of the hierarchy with square brackets. For example:

    {
    uniqueName: "Date.Month",
    filter: {
    members: ["Date.Month.May"]
    }
    }
  2. Also, please note that one hierarchy can not be placed on the grid and into report filters at the same time. Report filters serve for filtering by the hierarchy absent on an actual grid. Therefore, the following part should be excluded as well:

    "reportFilters": [
    {
    "uniqueName": "Country",
    "filter": {
    "members": [
    "Country.[France]"
    ]
    }
    }
    ]

Finally, our team would like to notice that it is always possible to configure the desired view through UI and save the report using the “Save” button on the Toolbar. It allows further retrieving the configured view.
 
We sure hope it works for you.
Do not hesitate to contact us in case of additional questions.
 
Best regards,
WebDataRocks Team