cancel
Showing results for 
Search instead for 
Did you mean: 

Dashboard filter date format in JAQL

pswami
8 - Cloud Apps
8 - Cloud Apps

I'm looking for two scenario
1.  Sort default data filter desc
2.  in JAQL object to set date filter to 'days', the following script is used and need your help on set date format to 'days' and sort to descending order...Help and How-To

Current: without date only format 

pswami_0-1727048301640.png

Expect like this - date format and need descending ( max date first)

pswami_1-1727048480245.png

 

attached the  script and if any one suggest to add date format  ("level": "days") and filter default display date descending order....

 

widget.on('initialized', function () {
 
    function runHTTP(jaql) {
 
        // Use $internalHttp service if exists
        const $internalHttp = prism.$injector.has("base.factories.internalHttp") ?
            prism.$injector.get("base.factories.internalHttp") : null;
 
        const ajaxConfig = {
 
            url: "/api/datasources/" + encodeURIComponent(jaql.datasource.title) + "/jaql",
 
            method: "POST",
 
            data: JSON.stringify(jaql),
 
            contentType: "application/json",
 
            dataType: "json",
 
            async: false,
 
            // Needed for WAT authentication
            xhrFields: {
                withCredentials: true
            }
 
        };
 
        const httpPromise = $internalHttp ? $internalHttp(ajaxConfig, false) : $.ajax(ajaxConfig);
 
        // Return response
        return httpPromise;
 
    }
 
 
    function generateJAQL(datasourceTitle, dimension, sortOrder) {
 
        jaqlObj = {
            "datasource": {
                "title": datasourceTitle,
            },
            "metadata": [
                {
                    "jaql": {
                        "dim": dimension,
                        "sort": sortOrder
 
                    }
                }
            ],
            "offset": 0,
            "count": 1
 
        }
 
        return jaqlObj;
 
 
    }
 
    //prism.activeDashboard.filters.clear(); //Clears current filters
    //alert('Dashboard filters cleared');
 
    prism.activeDashboard.defaultFilters.forEach(function (filter, index) { //Loop through each default filter and apply to current dashboard filters
 
        if (index != prism.activeDashboard.defaultFilters.length - 1) { //Does not refresh filter if it is not the last filter
            //alert(index);
            prism.activeDashboard.filters.update(filter, {
                save: false,
                refresh: false,
                unionIfSameDimensionAndSameType: true
            });
        }
        else {//Only refresh dashboard on the last filter
            //  alert('last one');
            prism.activeDashboard.filters.update(filter, {
                save: false,
                refresh: true,
                unionIfSameDimensionAndSameType: true
            });
        }
    })
 
 
    runHTTP(generateJAQL("smodel", "[Date_filter.date_list]", "desc")).then((API_Response) => {
        const filterObject = prism.activeDashboard.filters.item("[Date_filter.date_list]");   
        let firstValue = API_Response.data.values[0][0].data;
        filterObject.jaql.filter = {
            "explicit": true,
            "multiSelection": true,
"members": [
// default select first (max) date
                firstValue  
            ]
        }
 
        var dashboardRefreshedAfterFilter = false;
 
        if (dashboardRefreshedAfterFilter == false) {
            dashboard.refresh()
        }
 
        var dashboardRefreshedAfterFilter = true;
 
    });
 
 
})

 

 

4 REPLIES 4

DRay
Community Team Leader
Community Team Leader

Hi @pswami,

Thank you for reaching out. I would like to connect you with a technical resource to review your question. They will be able to review your use-case and help get you up and running. Can you message me directly and tell me the company you are with so I can get you connected?

Thank you. 

David Raynor (DRay)

pswami
8 - Cloud Apps
8 - Cloud Apps

thanks you David for looking 
Sisense contract with EIS and client is Allstate Benefit insurance
EIS contact Victor Polotsky ([email protected])
my contact Prakash Swami ([email protected])
please let me know any more details or setup quick call to walk through, this will really helps for my OCT 20th prod release in my side.
Thanks

DRay
Community Team Leader
Community Team Leader

Thank you @pswami.

I have reached out to your account team to get the ball rolling. You should hear from them soon. If you don't hear by early next week let me know.

David Raynor (DRay)

pswami
8 - Cloud Apps
8 - Cloud Apps

Perfect thanks David