{ "title": "Either-Or Date Filters", "oid": "64da66fb4faf000033a58e2d", "desc": "", "source": null, "type": "dashboard", "style": { "palette": { "name": "Vivid", "colors": [ "#00cee6", "#9b9bd7", "#6EDA55", "#fc7570", "#fbb755", "#218A8C" ] } }, "layout": { "instanceid": "5490A-D2A3-19", "type": "columnar", "columns": [ { "width": 100, "cells": [ { "subcells": [ { "elements": [ { "minHeight": 64, "maxHeight": 2048, "minWidth": 64, "maxWidth": 2048, "height": "52px", "defaultWidth": 128, "widgetid": "64da67044faf000033a58e31" } ], "width": 100, "stretchable": false, "pxlWidth": 843, "index": 0 } ] }, { "subcells": [ { "elements": [ { "minHeight": 128, "maxHeight": 2048, "minWidth": 128, "maxWidth": 2048, "height": "352px", "defaultWidth": 512, "widgetid": "64da67034faf000033a58e2f", "autoHeight": "352px" } ], "width": 100, "stretchable": false, "pxlWidth": 843, "index": 0 } ] } ], "pxlWidth": 843, "index": 0 } ], "container": {} }, "original": null, "dataExploration": false, "lastOpened": null, "previewLayout": [], "datasource": { "fullname": "localhost/Sample Healthcare", "id": "localhost_aSampleIAAaHealthcare", "address": "LocalHost", "database": "aSampleIAAaHealthcare", "live": false, "title": "Sample Healthcare" }, "filters": [ { "jaql": { "table": "Admissions", "column": "Admission_Time", "dim": "[Admissions.Admission_Time (Calendar)]", "datatype": "datetime", "merged": true, "datasource": { "fullname": "localhost/Sample Healthcare", "id": "localhost_aSampleIAAaHealthcare", "address": "LocalHost", "database": "aSampleIAAaHealthcare", "live": false, "title": "Sample Healthcare" }, "firstday": "mon", "locale": "en-us", "level": "years", "title": "Admission Time", "collapsed": true, "isDashboardFilter": true, "filter": { "explicit": true, "multiSelection": true, "members": [ "2013-01-01T00:00:00" ], "all": true } }, "instanceid": "BFA6B-9CE1-DD", "isCascading": false, "disabled": false }, { "jaql": { "table": "Admissions", "column": "Discharge_Time", "dim": "[Admissions.Discharge_Time (Calendar)]", "datatype": "datetime", "merged": true, "datasource": { "fullname": "localhost/Sample Healthcare", "id": "localhost_aSampleIAAaHealthcare", "address": "LocalHost", "database": "aSampleIAAaHealthcare", "live": false, "title": "Sample Healthcare" }, "firstday": "mon", "locale": "en-us", "level": "years", "title": "Discharge Time", "collapsed": true, "isDashboardFilter": true, "filter": { "explicit": true, "multiSelection": true, "members": [ "2011-01-01T00:00:00" ] } }, "instanceid": "9263E-9772-C8", "isCascading": false, "disabled": false } ], "editing": true, "parentFolder": "62598ededa957a0037bb48c6", "settings": { "autoUpdateOnFiltersChange": true }, "filterRelations": [], "filterToDatasourceMapping": {}, "script": "/*\nWelcome to your Dashboard's Script.\n\nTo learn how you can access the Widget and Dashboard objects, see the online documentation at https://sisense.dev/guides/js/extensions\n*/\n\n//Specify the names of the two filters, this is the only part of the code that requires your input\nvar date1Name = 'Admission Time';\nvar date2Name = 'Discharge Time';\n\n//Find the first date filter by name\nvar date1Filter = dashboard.filters.$$items.find((item) => {\n\tif (item.jaql && item.jaql.title.indexOf(date1Name) !== -1) {\n\t\treturn true;\n\t}\n});\n\n//Get the original JAQL filter state of the first date filter\nvar date1FilterJAQL = date1Filter.jaql.filter;\n\n//Find the second date filter by name\nvar \tdate2Filter = dashboard.filters.$$items.find((item) => {\n\tif (item.jaql && item.jaql.title.indexOf(date2Name) !== -1) {\n\t\treturn true;\n\t}\n});\t\n\n//Get the original JAQL filter state of the second date filter\nvar date2FilterJAQL = date2Filter.jaql.filter;;\n\n//Every time a filter is changed, this code is executed\ndashboard.on('filterschanged',function(d) {\n\n\t//Find the first date filter by name again and add it to a new variable to hold the new filter values\n\tdate1Filter_new = dashboard.filters.$$items.find((item) => {\n\t\tif (item.jaql && item.jaql.title.indexOf(date1Name) !== -1) {\n\t\t\treturn true;\n\t\t}\n\t});\n\t\n\t//Get the new JAQL filter state of the first date filter\n\tvar date1FilterJAQL_new = date1Filter_new.jaql.filter;\n\n\t//Check if either date is already set to Include All\n\tif(!(date1Filter.jaql.filter.all == true || date2Filter.jaql.filter.all == true)) {\n\t\t\n\t\t//Check if the new filter state is different from the original filter state, which means the filter has been modified\n\t\tif(date1FilterJAQL_new != date1FilterJAQL) {\n\t\t\t//If so, then reset the second date filter to Include All\n\t\t\tdate2Filter.jaql.filter.all = true;\n\t\t}\n\t\t\n\t\t//Update the value of the original filter state with the new filter state\n\t\tdate1FilterJAQL = date1FilterJAQL_new;\n\t}\n\t\n\t\n\t//Find the second date filter by name again and add it to a new variable to hold the new filter values\n\tdate2Filter_new = dashboard.filters.$$items.find((item) => {\n\t\tif (item.jaql && item.jaql.title.indexOf(date2Name) !== -1) {\n\t\t\treturn true;\n\t\t}\n\t});\n\t\n\t//Get the new JAQL filter state of the second date filter\n\tvar date2FilterJAQL_new = date2Filter_new.jaql.filter;\n\n\t\n\t//Check if either date is already set to Include All\n\tif(!(date1Filter.jaql.filter.all == true || date2Filter.jaql.filter.all == true)) {\n\t\t\n\t\t//Check if the new filter state is different from the original filter state, which means the filter has been modified\n\t\tif(date2FilterJAQL_new != date2FilterJAQL) {\n\t\t\t//If so, then reset the first date filter to Include All\n\t\t\tdate1Filter.jaql.filter.all = true;\n\t\t}\n\t\t\n\t\t//Update the value of the original filter state with the new filter state\n\t\tdate2FilterJAQL = date2FilterJAQL_new;\n\t}\n\n});\n", "widgets": [ { "title": "", "type": "pivot2", "subtype": "pivot2", "oid": "64da67034faf000033a58e2f", "desc": null, "source": null, "datasource": { "fullname": "localhost/Sample Healthcare", "id": "localhost_aSampleIAAaHealthcare", "address": "LocalHost", "database": "aSampleIAAaHealthcare", "live": false, "title": "Sample Healthcare" }, "selection": null, "metadata": { "ignore": { "dimensions": [], "ids": [], "all": false }, "panels": [ { "name": "rows", "items": [ { "jaql": { "table": "Admissions", "column": "Admission_Time", "dim": "[Admissions.Admission_Time (Calendar)]", "datatype": "datetime", "merged": true, "level": "months", "title": "Months in Admission_Time" }, "instanceid": "ADBB0-D1BF-85", "panel": "rows", "field": { "id": "[Admissions.Admission_Time (Calendar)]_years", "index": 0 }, "format": { "mask": { "years": "yyyy", "quarters": "yyyy Q", "months": "MM/yyyy", "weeks": "ww yyyy", "days": "shortDate", "minutes": "HH:mm", "dateAndTime": "MM/dd/y HH:mm", "isdefault": true } }, "hierarchies": [ "calendar", "calendar - weeks" ] }, { "jaql": { "table": "Admissions", "column": "Discharge_Time", "dim": "[Admissions.Discharge_Time (Calendar)]", "datatype": "datetime", "merged": true, "level": "months", "title": "Months in Discharge_Time" }, "instanceid": "8DE9B-448C-7F", "panel": "rows", "field": { "id": "[Admissions.Discharge_Time (Calendar)]_years", "index": 1 }, "format": { "mask": { "years": "yyyy", "quarters": "yyyy Q", "months": "MM/yyyy", "weeks": "ww yyyy", "days": "shortDate", "minutes": "HH:mm", "dateAndTime": "MM/dd/y HH:mm", "isdefault": true } }, "hierarchies": [ "calendar", "calendar - weeks" ] } ] }, { "name": "values", "items": [ { "jaql": { "table": "Admissions", "column": "ID", "dim": "[Admissions.ID]", "datatype": "numeric", "agg": "count", "title": "# of Admissions" }, "instanceid": "FF616-D0D6-55", "panel": "measures", "field": { "id": "[Admissions.ID]_count", "index": 2 }, "format": { "mask": { "type": "number", "t": true, "b": true, "separated": true, "decimals": "auto", "isdefault": true }, "color": { "type": "color" } } } ] }, { "name": "columns", "items": [] }, { "name": "filters", "items": [] } ], "usedFormulasMapping": {} }, "style": { "scroll": false, "pageSize": 25, "automaticHeight": true, "colors": { "rows": true, "columns": false, "headers": false, "members": false, "totals": false }, "narration": { "enabled": false, "display": "above", "format": "bullets", "verbosity": "medium", "up_sentiment": "good", "aggregation": "sum", "labels": [ { "id": "months_in_admission_time", "title": "Months in Admission_Time", "singular": "Months in Admission_Time", "plural": "Months in Admission_Time" }, { "id": "months_in_discharge_time", "title": "Months in Discharge_Time", "singular": "Months in Discharge_Time", "plural": "Months in Discharge_Time" } ] } }, "instanceid": "D5E08-7E14-89", "query": { "datasource": { "fullname": "localhost/Sample Healthcare", "id": "localhost_aSampleIAAaHealthcare", "address": "LocalHost", "database": "aSampleIAAaHealthcare", "live": false, "title": "Sample Healthcare" }, "grandTotals": { "title": "Grand Total" }, "metadata": [ { "jaql": { "table": "Admissions", "column": "Admission_Time", "dim": "[Admissions.Admission_Time (Calendar)]", "datatype": "datetime", "merged": true, "level": "months", "title": "Months in Admission_Time" }, "instanceid": "ADBB0-D1BF-85", "panel": "rows", "field": { "id": "[Admissions.Admission_Time (Calendar)]_years", "index": 0 }, "format": { "mask": { "years": "yyyy", "quarters": "yyyy Q", "months": "MM/yyyy", "weeks": "ww yyyy", "days": "shortDate", "minutes": "HH:mm", "dateAndTime": "MM/dd/y HH:mm", "isdefault": true } }, "hierarchies": [ "calendar", "calendar - weeks" ], "handlers": [ {} ] }, { "jaql": { "table": "Admissions", "column": "Discharge_Time", "dim": "[Admissions.Discharge_Time (Calendar)]", "datatype": "datetime", "merged": true, "level": "months", "title": "Months in Discharge_Time" }, "instanceid": "8DE9B-448C-7F", "panel": "rows", "field": { "id": "[Admissions.Discharge_Time (Calendar)]_years", "index": 1 }, "format": { "mask": { "years": "yyyy", "quarters": "yyyy Q", "months": "MM/yyyy", "weeks": "ww yyyy", "days": "shortDate", "minutes": "HH:mm", "dateAndTime": "MM/dd/y HH:mm", "isdefault": true } }, "hierarchies": [ "calendar", "calendar - weeks" ], "handlers": [ {} ] }, { "jaql": { "table": "Admissions", "column": "ID", "dim": "[Admissions.ID]", "datatype": "numeric", "agg": "count", "title": "# of Admissions" }, "instanceid": "FF616-D0D6-55", "panel": "measures", "field": { "id": "[Admissions.ID]_count", "index": 2 }, "format": { "mask": { "type": "number", "t": true, "b": true, "separated": true, "decimals": "auto", "isdefault": true }, "color": { "type": "color", "color": "transparent" } }, "handlers": [ {}, {} ] }, { "jaql": { "table": "Admissions", "column": "Admission_Time", "dim": "[Admissions.Admission_Time (Calendar)]", "datatype": "datetime", "merged": true, "datasource": { "fullname": "localhost/Sample Healthcare", "id": "localhost_aSampleIAAaHealthcare", "address": "LocalHost", "database": "aSampleIAAaHealthcare", "live": false, "title": "Sample Healthcare" }, "firstday": "mon", "locale": "en-us", "level": "years", "title": "Admission Time", "collapsed": true, "isDashboardFilter": true, "filter": { "explicit": false, "multiSelection": true, "all": true } }, "disabled": false, "isCascading": false, "instanceid": "BFA6B-9CE1-DD", "panel": "scope" }, { "jaql": { "table": "Admissions", "column": "Discharge_Time", "dim": "[Admissions.Discharge_Time (Calendar)]", "datatype": "datetime", "merged": true, "datasource": { "fullname": "localhost/Sample Healthcare", "id": "localhost_aSampleIAAaHealthcare", "address": "LocalHost", "database": "aSampleIAAaHealthcare", "live": false, "title": "Sample Healthcare" }, "firstday": "mon", "locale": "en-us", "level": "years", "title": "Discharge Time", "collapsed": true, "isDashboardFilter": true, "filter": { "explicit": true, "multiSelection": true, "members": [ "2011-01-01T00:00:00" ] } }, "disabled": false, "isCascading": false, "instanceid": "9263E-9772-C8", "panel": "scope" } ], "m2mThresholdFlag": 0 }, "drillToDashboardConfig": { "drilledDashboardPrefix": "_drill", "drilledDashboardsFolderPrefix": "", "displayFilterPane": true, "displayDashboardsPane": true, "displayToolbarRow": true, "displayHeaderRow": true, "volatile": false, "hideDrilledDashboards": true, "hideSharedDashboardsForNonOwner": true, "drillToDashboardMenuCaption": "Jump to dashboard", "drillToDashboardRightMenuCaption": "Jump to ", "drillToDashboardNavigateType": 2, "drillToDashboardNavigateTypePivot": 2, "drillToDashboardNavigateTypeCharts": 1, "drillToDashboardNavigateTypeOthers": 3, "excludeFilterDims": [], "includeFilterDims": [], "drilledDashboardDisplayType": 2, "dashboardIds": [], "modalWindowResize": false, "showFolderNameOnMenuSelection": false, "resetDashFiltersAfterJTD": false, "sameCubeRestriction": true, "showJTDIcon": true, "sendPieChartMeasureFiltersOnClick": true, "forceZeroInsteadNull": false, "mergeTargetDashboardFilters": false, "drillToDashboardByName": false }, "wasRendered": false, "realTimeRefreshing": false, "options": { "dashboardFiltersMode": "filter", "selector": false, "triggersDomready": true, "drillToAnywhere": true, "autoUpdateOnEveryChange": true, "interactivePivot": { "enable": false } }, "dashboardid": "64da66fb4faf000033a58e2d", "lastOpened": null }, { "title": "RICHTEXT_MAIN.TITLE", "type": "richtexteditor", "subtype": "richtexteditor", "oid": "64da67044faf000033a58e31", "desc": null, "source": null, "datasource": { "fullname": "localhost/Sample Healthcare", "id": "localhost_aSampleIAAaHealthcare", "address": "LocalHost", "database": "aSampleIAAaHealthcare", "live": false, "title": "Sample Healthcare" }, "selection": null, "metadata": { "ignore": { "dimensions": [], "ids": [], "all": false }, "panels": [], "usedFormulasMapping": {} }, "style": { "content": { "html": "
Question: https://community.sisense.com/t5/developer-forum/filter-based-on-one-filter-selection-or-another/td-p/16941
", "vAlign": "valign-middle", "bgColor": "#FFFFFF", "textAlign": "center" } }, "instanceid": "2F22B-8F47-8D", "wasRendered": false, "realTimeRefreshing": false, "options": { "triggersDomready": true, "hideFromWidgetList": true, "disableExportToCSV": true, "disableExportToImage": true, "toolbarButton": { "css": "add-rich-text", "tooltip": "RICHTEXT_MAIN.TOOLBAR_BUTTON" }, "selector": false, "disallowSelector": true, "disallowWidgetTitle": true, "supportsHierarchies": false, "dashboardFiltersMode": "filter" }, "dashboardid": "64da66fb4faf000033a58e2d", "lastOpened": null } ], "hierarchies": [] }