Dashboard filter date format in JAQL
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
Expect like this - date format and need descending ( max date first)
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;
});
})
pswami
Posted 1 year ago·Last reply 1 year ago
4 comments
DRay
·1 year agoHi 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.
pswami
OP1 year agothanks you David for looking
Sisense contract with EIS and client is Allstate Benefit insurance
EIS contact Victor Polotsky (vpolotsky@eisgroup.com)
my contact Prakash Swami (pswami@allstate.com)
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
·1 year agoThank 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.
pswami
OP1 year agoPerfect thanks David