Sisense Community logo
     
    • Community Feedback
    • Chapters
    • Events
    • Forums
      • Help and How To
      • Product Feedback Forum
      • Strategy & Use Cases
    • Blogs
    • KB Docs
      • KB Docs
      • Add-Ons & Plug-Ins
      • APIs
      • Best Practices
      • Blox
      • CDT
      • Cloud Managed Service
      • Data Models
      • Data Sources
      • Embedding Analytics
      • How-Tos & FAQs
      • Onboarding
      • PySisense
      • Security
      • Sisense Administration
      • Sisense Intelligence & AI
      • Troubleshooting
      • Widget & Dashboard Scripts
    • Support
    • Learning
      • Sisense Academy: Free Courses and Certifications
      • Official Developer Documentation
      • Official Product Documentation
      • Official Sisense Youtube Channel
      • Sisense Compose SDK Playground
      • Official Sisense Discord
    • Use Case Gallery
    •      
    Discussions
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
    Discussions
    • TagsChevronRightIcon
    Filters
    • Mia Isaacson

      Help and How-To

               
      Mia Isaacson
      Posted 1 month ago
      Dashboard script: automatically reset filters to default when a dashboard is opened
                                               

      Hey everyone 👋 Here's one that comes up more than you'd think. You've got a dashboard with filters. A user applies a bunch of selections, and the next time they (or someone else) opens it, those filters are still there from the last session. Depending on your use case, that might be exactly what you want... but sometimes it isn't. If you'd rather your dashboard always open in a clean, predictable state, with filters resetting to the defaults you set at design time, this dashboard script does exactly that. Every time the dashboard is activated, it removes whatever filters are currently applied and restores the defaults automatically. Here's the full script: dashboard.on("activated", (e, args) => { const dashFilters = args.dashboard.filters; dashFilters.$$items = dashFilters.$$items.splice(0, dashFilters.$$items.length); let filters = args.dashboard.defaultFilters; var options = { save: true, refresh: true, unionIfSameDimensionAndSameType: false, }; if (!Array.isArray(filters)) { filters = [filters]; } dashFilters.update(filters, options); }); Here's what each part is doing: Trigger This fires whenever the dashboard becomes active (when a user opens it or navigates to it). That's the moment everything below kicks off. dashboard.on("activated", (e, args) => { ... }) Step 1: Clear the current filters This grabs the live filter collection and empties it out completely — whatever the user had applied before is gone. const dashFilters = args.dashboard.filters; dashFilters.$$items = dashFilters.$$items.splice(0, dashFilters.$$items.length); Step 2: Grab the default filters defaultFilters is the filter state saved at design time. Whatever you configured as the intended starting point when you built the dashboard. const filters = args.dashboard.defaultFilters; Step 3: Apply the defaults This normalizes the filters into an array, then applies them back with save: true so the reset persists, and refresh: true so the data reloads immediately. The unionIfSameDimensionAndSameType: false setting makes sure it replaces rather than tries to merge with anything. var options = { save: true, refresh: true, unionIfSameDimensionAndSameType: false, }; if (!Array.isArray(filters)) { filters = [filters]; } dashFilters.update(filters, options); When would you actually use this? Shared dashboards where you don't want one user's filter selections to carry over for the next person who opens it Executive or presentation dashboards where the default view is intentional and should always be what people land on Dashboards embedded in portals or apps where a consistent starting state matters Anywhere you've had someone complain that the dashboard "looks different than it usually does" — often it's just leftover filters from a previous session One thing worth knowing The $$items approach in Step 1 is manipulating an internal Sisense array directly. The $$ prefix is a convention for internal Angular properties. It works well, but it's worth keeping in mind that if Sisense changes the internal structure down the road, that line could break without much warning. Something to keep an eye on if you're on this script after an upgrade. Hope this is useful for someone, and happy to answer questions if you run into anything! Mia from QBeeQ, a Sisense Gold Implementation Partner www.qbeeq.io

                                             
      0
               
    • Rose Holmes-Minton

      Help and How-To

               
      Rose Holmes-Minton
      Posted 3 months ago • Last reply 3 months ago
      Set a background dashboard filter using Javascript
                               

      I am trying to set a background dashboard filter using JavaScript. Any suggestions?  

                                             
      3
               
    • EMS_Data_Guy

      Help and How-To

               
      EMS_Data_Guy
      Posted 5 months ago • Last reply 5 months ago
      Filter Dashboard by Last 24 Hours
               

      In my industry, we mostly work 12 or 24 hour shifts with the most common shift change time being 0600. I have a great dashboard built that looks at the last day and calculates time on task. The only problem is that the only filter that comes close is 'Yesterday' which is looking at 00:00-23:59 on the last calendar day. I need to be able to look at 06:00 on day one to 06:00 the next day.  I tried a couple of tweaks by using the 'Advanced' feature under the filter but none of them worked. Including trying a fractional offset of 0.75. My goal is to have this auto run at 0800 every morning. So, the 'advanced' tab would look like this,  { "last": { "count": 24, "offset": 2 } } I can't make that work now though because the advanced tab only lets you edit the filter for the time period selected and hours isn't a choice. We are using an embedded version of Sisense so I can't edit anything in 'The Cube'.

                                             
      4
               
    • Luke Flett

      Help and How-To

               
      Luke Flett
      Posted 6 months ago • Last reply 5 months ago
      Filter to only show Relevant Dimension Values
                                       

      Morning Sisense community!  I have my Fact Table and a related Dimension Table . My dimension table contains more unique values than are actually present in the fact table. When I use a field from the Dimension Table as a filter, the filter displays all values from the dimension, even those that have no corresponding fact records . I only want the filter to show dimension values that are relevant to the data in the fact table . Example Tables: fact_table   dimension_table   id dim_id dim_id dim_name 1 1 1 one 2 2 2 two 3 1 3 three 4 2 4 four fact_table and dimension_table have a relationship in the EC based on dim_id Desired Outcome: In the filter based on dim_name, I only want to see "one" and "two" , but currently, I see all four: "one," "two," "three," and "four." How do I achieve my desired outcome?

                                             
      5
               
    • Astroraf

      Help and How-To

               
      Astroraf
      Posted 9 months ago • Last reply 8 months ago
      Custom Filtering to allow users to filter for specific zip codes
                       

      Hi DRay​   and friends, I am trying to allow my users to filter for multiple different zip codes, and specific zip codes to their use cases. Right now in Sisense a user would have to search and click the ones they want, I know with custom code filtering then can give the codes they want to filter for. Is there any easier way, maybe BloX, where a user can search/filter for multiple zip codes without looking them up/without using the custom code filter option? example:   {   "explicit": true,   "multiSelection": true,   "members": [     33825,     34420,     33834,     33525,     34432,     32134,     33843,     34690,     34691,     33852,     33810,     34638,     34639,     33549,     33559,     33558,     34652,     34470,     34471,     34472,     34473,     34474,     34475,     34476,     34479,     34480,     34481,     34482,     33556,     32179,     34683,     34684,     33576,     33870,     33872,     33875,     33584,     34488,     34491,     33604,     33605,     33610,     33612,     33613,     33614,     33617,     33618,     33619,     33624,     33625,     33637,     33647,     33603,     33607,     33609,     33615,     33626,     33634,     33635,     34689,     33592,     33873,     33543,     33545,     33544,     33540,     33541,     33542,     33823,     33827,     33830,     34714,     33523,     33837,     33896,     33897,     33838,     33839,     33841,     33844,     33847,     33855,     33849,     34759,     33850,     33851,     33853,     33859,     33898,     33801,     33803,     33805,     33809,     33811,     33812,     33813,     33815,     33854,     33860,     33856,     33868,     33867,     33877,     34787,     33880,     33881,     33884   ] }

                                             
      8