Cognos Analytics

 View Only
  • 1.  Dashboard - Hide Filters pane by default

    Posted Mon May 13, 2024 12:12 PM

    Is there a way of hiding the filter pane in dashboards so it shows a collapsed view when the user opens the dashboard up???



    ------------------------------
    Eric Mueller
    ------------------------------


  • 2.  RE: Dashboard - Hide Filters pane by default

    Posted Mon May 20, 2024 04:34 PM
      |   view attached

    Not out of the box. If you have a filter applied as a default setting it will always show the filter bar on open. I created a Cognos extension that checks for the loading of widgets on the page and closes the filter bar once the page is loaded. Use the widgetID and add it to the Widget ID's box. You can decrease the opacity or push the z index to be behind all visible widgets to hide it. I have tested it only with 11.2.4 and 12. Not certain if it will work with 11.7. 

    I needed this function so that I could make the default filters come from a report which embedded my dashboard and passed the filters to the dashboard. It was a pretty crazy hack to use report filters for a dashboard and I needed to hide the dashboard filters to make it easier for users to know where to change filters. I hope this is helpful for you!



    ------------------------------
    Michael Webb
    ------------------------------

    Attachment(s)

    zip
    DashboardReady.zip   1.00 MB 1 version


  • 3.  RE: Dashboard - Hide Filters pane by default

    IBM Champion
    Posted Tue May 21, 2024 11:20 AM

    Hi Michael, 

    How did you manage this? 

    "...default filters come from a report which embedded my dashboard and passed the filters to the dashboard." 

    I'm not aware of a way to pass filters from a report to a dashboard but I would like to know. 

    Best regards, 

    Philipp 



    ------------------------------
    Philipp Hornung
    Business Intelligence Manager
    Techniker Krankenkasse
    Hamburg Germany
    #IBMChampion
    ------------------------------



  • 4.  RE: Dashboard - Hide Filters pane by default

    Posted Tue May 21, 2024 12:34 PM
    Edited by Michael Webb Tue May 21, 2024 12:46 PM

    Hi Philipp,

    My method is a little convoluted and specific to my use case. Our data warehouse has a fuzzy lookup of multiple columns for organization parameters so my mappings required validating multiple columns against each other so it's hard to give you a lot of details without getting confusing so I will tell you my steps and then generalize it for you. Also it doesn't work if you select too many parameters but this is how I did it. 

    I created a report page with a prompt and a list that gets filtered by the prompt and I added an several HTML items on the page. the HTML items held a couple spans with information from the query the prompt generates, and an empty iframe which we render the dashboard inside. 

    I then created a custom control called DashURL which uses the dashprompt.js in the file I shared. This custom control scrapes the prompt api to get all prompt key value pairs and then maps them to a new object structure. My use case required validating the prompt output with the values returned in the list because my data sources for the prompt and the dashboard were different so all the prefixes and column names needed to be mapped out. 

    This object structure is the same one that dashboards use to drill through to another dashboard and then it gets appended to the url. The problem is the url length can max out pretty easily so its best used if you don't need to select many values in a single prompt. I want to note, that this object structure is also verbose. 

    The way the object structure works is you need to define a scope (page, widget) through getting the widgetId or the highest level widgetid in the report specification for the dashboard. You need to be able to have the name of the column you want to filter, operator which is the ( in, and, or) for the filter, and the filter values which is an object of display and value. Then you make an array of all the filters you want to apply and place them in an object formed like the one below:

    {
      options: {
        overrideExistingFiltersOnly: true/false,
        matchMetadataAcrossSources: true/false,
      },
      filters: [
        {
          scope: widgetId,
          columnId: columnName,
          operator: "in",
          values: {
            u: "displayValue -> [valueValue]",
            d: "valueValue"
          }
        }
      ],
    }

    I then encodedURI this object and added it to the dashboard url like this:
    .../bi/?perspective=dashboard&pathRef=...&closeWindowOnLastView=true&ui_appbar=false&ui_navbar=false&shareMode=embedded&action=view&mode=dashboard&filters=${encodedFilterObject}
    Then I take this new url and add it as the src for the iframe in the html item we placed on the page.

    Now at the time this method had some drawbacks. I believe it is changed now in 12.0.3 but in previous versions we had an issue in reports where search and select prompts would rerender the page when you ran the search query. This would cause the dashboard to also rerender and was cause for slow performance and extra fetch requests for the dashboard on each render. Also if you selected too many filter selections it would max our the URL length and the dashboard wouldn't grab all the filters or any of them. 

    My future solution is to create a similar method using the cross window context api for dashboards and have prompts pass the values to the dashboard that way. I think that is the best possible way to use report prompts to manage the dashboard filters. Since the newer prompts now can run without rerendering the page it should make it much easier to implement. 

    Hope that helps!

    p.s. I also want to use the custom control datastore instead of lists for future versions to make the logic less complicated. 




    ------------------------------
    Michael Webb
    ------------------------------



  • 5.  RE: Dashboard - Hide Filters pane by default
    Best Answer

    Posted Tue May 21, 2024 01:42 PM
      |   view attached

    I made a simple dashboard and got a sample of what a simple url could look like. This is using the American Time Use dataset and just a single filter on age range. I included the dashboard specifications for you as well. You can copy and paste them in a new dashboard and then play with the url filter parameters.

    &filters=%5B%7B%22id%22%3A%22M1_American_time_use_xlsx.Age_Range%22%2C%22columnId%22%3A%22M1_American_time_use_xlsx.Age_Range%22%2C%22values%22%3A%5B%7B%22d%22%3A%2220-29%22%2C%22u%22%3A%2220-29%22%7D%2C%7B%22d%22%3A%2230-39%22%2C%22u%22%3A%2230-39%22%7D%2C%7B%22d%22%3A%2240-49%22%2C%22u%22%3A%2240-49%22%7D%2C%7B%22d%22%3A%2250-59%22%2C%22u%22%3A%2250-59%22%7D%2C%7B%22d%22%3A%2260-69%22%2C%22u%22%3A%2260-69%22%7D%2C%7B%22d%22%3A%2270-79%22%2C%22u%22%3A%2270-79%22%7D%2C%7B%22d%22%3A%2280%2B%22%2C%22u%22%3A%2280%2B%22%7D%2C%7B%22d%22%3A%220-19%22%2C%22u%22%3A%220-19%22%7D%5D%2C%22excludedValues%22%3A%5B%5D%2C%22operator%22%3A%22in%22%2C%22type%22%3Anull%2C%22assetId%22%3A%22i72F95B15ADD44CC29FA27028BE28D0DD%22%2C%22scope%22%3A%22global%22%7D%5D

    &
    filters = [{
        "id": "M1_American_time_use_xlsx.Age_Range",
        "columnId": "M1_American_time_use_xlsx.Age_Range",
        "values": [{
            "d": "20-29",
            "u": "20-29"
        }, {
            "d": "30-39",
            "u": "30-39"
        }, {
            "d": "40-49",
            "u": "40-49"
        }, {
            "d": "50-59",
            "u": "50-59"
        }, {
            "d": "60-69",
            "u": "60-69"
        }, {
            "d": "70-79",
            "u": "70-79"
        }, {
            "d": "80+",
            "u": "80+"
        }, {
            "d": "0-19",
            "u": "0-19"
        }],
        "excludedValues": [],
        "operator": "in",
        "type": null,
        ,
        "scope": "global"
    }]



    ------------------------------
    Michael Webb
    ------------------------------

    Attachment(s)

    json
    dashboardspec.json   39 KB 1 version


  • 6.  RE: Dashboard - Hide Filters pane by default

    IBM Champion
    Posted Thu May 23, 2024 02:35 AM

    Hi Eric, 

    Thanks for sharing your approach, I got got some really interesting ideas from it. Actually I wasn't aware that the key word filters is also supported for dashboard URLs. Hopefully IBM will make more out of it (like dashboard views or drillt-hroughs from report to dashboard).

    Best regards,

    Philipp



    ------------------------------
    Philipp Hornung
    Business Intelligence Manager
    Techniker Krankenkasse
    Hamburg Germany
    #IBMChampion
    ------------------------------



  • 7.  RE: Dashboard - Hide Filters pane by default

    Posted Thu May 23, 2024 11:31 AM

    Hi Philip, 

    Yeah IBM didn't publish this url filter anywhere in their documentation but I found it when I used this accelerator extensions for sharing dashboards with filters and it unlocked it for me. I have no idea why they never showed us how to use it or explain all the different parameters, it's something I have seen asked a billion times in the community discussions. 

    EXT00063 (ibm.com)



    ------------------------------
    Michael Webb
    ------------------------------



  • 8.  RE: Dashboard - Hide Filters pane by default

    Posted Thu May 23, 2024 06:43 AM

    Hi Michael,

    Thanks for the extension, this is great and works just as you described. I wonder if you have any tips on documents / tutorials that I can look at to get some compatibly in creating my own custom widgets. I wouldn't know where to start with this but it strikes me that its almost essential to get to grips with this if you want to get anything out of the ordinary done in dashboards.

    Regards,

    Eric



    ------------------------------
    Eric Mueller
    ------------------------------



  • 9.  RE: Dashboard - Hide Filters pane by default

    Posted Thu May 23, 2024 11:28 AM
    Edited by Michael Webb Thu May 23, 2024 11:38 AM

    Hi Eric, 

    You're very welcome. Honestly, there aren't enough examples or clear documentation for making dashboard extensions. I couldn't have made this extension without Paul Mendelson's help. A year ago, he gave me a blank widget script that helped me figure out how to get my code into a dashboard extension. He also introduced me to all the internal Cognos APIs, which aren't documented anywhere.

    If you're interested in coding your own widgets, I suggest starting with the official documentation and some tutorials on writing extensions. Additionally, visit the accelerator page and unzip and explore the files to learn how they work.

    I knew nothing about JavaScript three years ago, and it's been quite a journey to get this far. I still have a long way to go. I've included links to the resources I use to look up answers to my questions as a Cognos developer.

    Official IBM docs:

    Cognos Analytics Docs

    Scriptable Reports (Writing Cognos Extensions, and Custom Controls)

    Cognos Dashboard API

    @businessanalytics/customvis-lib (Visualization Documents)

    Cognos Analytics API Test Page (REST API Docs)

    Third Party Cognos Developer Resources:

    CognosPaul - Cognos tips, Cognos tricks, Cognos techniques: Cognos, Cognos, Cognos!

    ^^^^^ this is Paul Mendelson's personal Cognos blog and his experience goes back very far and is very active in the community. He also works for PMSquare which does some great consulting and teaching on their blog. Paul is the main creator of CogBox which is also sold by PMSquare (Free version also available)

    Analytics Blog - PMsquare

    Cognos Workshop: Creating Custom Visualizations (youtube.com)

    ^^^ Full tutorial and CLI setup for developing Custom Cognos report/dashboard visualizations. Definitely walkthrough this if you have the time. 

    GitHub - rnassif/Cognos-extensions: A collection of tutorials and extensions that can improve your IBM Cognos application

    CognosSkills (Time Casting Calculations)

    Cognos Analytics Blog (older 11.0 tips and tricks)

    datanerdjosh.com (Formerly - Cognos and Coffee Blog)



    ------------------------------
    Michael Webb
    ------------------------------