We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

Filter by date without selecting a date field

Answered
Younus M asked on April 8, 2022

Hi, 
Is there anyway to filter data without using a date field? In some scenarios we don't want to see the data field on the report but still want to filter the data by date. Is there a possibility to do this?
 
Thanks,
Younus

8 answers

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster April 8, 2022

Hello, Younus,
 
Thank you for reaching out to us.
 
Yes, it is possible to filter data by date without showing a date field on the grid. For such cases, we recommend defining the Report Filter in the Slice. It allows displaying different data subsets in the report without showing the field it was filtered by.
For example,

slice: {
reportFilters: [{
"uniqueName": "Date",
"filter": {
"query": {
"after": "2018-03-27"
}
}
}],
...
}

The report filter also can be configured from the UI in the Field List. As soon as you add the necessary field to the Report filters window and press "Apply", the report filter button will appear above the grid, where you can add the needed filter or choose some of the members. 
The report filter area can also be hidden on the grid by setting showReportFiltersArea property of the Options object to false:

options: {
grid: {
showReportFiltersArea: false
}
}

Feel free to check the following JSFiddle for reference: https://jsfiddle.net/flexmonster/har5egyb/
 
Please let us know if it works for you. You are welcome to contact us if other questions arise.
 
Kind regards,
Nadia

Public
Younus M April 11, 2022

So with this solution, I still need to add a date filter, this just hides the data filter correct? 

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster April 12, 2022

Hello, Younus,
 
Thank you for the response.
 
Yes, you are correct that the solution above requires date filtering in Flexmonster.
Alternatively, if you use, for example, Flexmonster Data Server, you can create an index with already filtered data. You can specify a query to define the subset of data filtered based on necessary dates. Then, pass the already filtered data set to the Data Server. This way, you don't need to define date filters in the report.
 
We hope it helps. You are welcome to write to us in case further questions arise.
 
Kind regards,
Nadia

Public
Younus M April 12, 2022

Ok, I see. 
Thanks!

Public
Younus M April 18, 2022

Is there anyway to dynamically add this before a request is made? I'm looking at the customizeAPIRequest but it seems a little confusing adding it onto a select request. If i try adding it during any other event it either loads the report twice or forces the report to load without allowing the user to select fields.
 
Younus

Public
Younus M April 18, 2022

Or if theres anything like getReportFilters? I don't see one for setReportFilters. And setFilter seems to operate differently, that requires the field to be selected to filter on. If something like setReportFilters doesn't exist I think that would be a great one to add.
 
Younus

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster April 19, 2022

Hi, Younus,
 
Thank you for the response.
 
We would suggest implementing the server filter - it allows filtering the data right on the application’s back end, so Flexmonster Pivot receives and shows only the subset of the data that meets filtering conditions. 
To achieve this, Flexmonster Data Server should be embedded into your project as a DLL – a separate flexible module. You are welcome to check our documentation for the detailed information: https://www.flexmonster.com/doc/getting-started-with-data-server-dll/
 
Please let us know if it works for you. Feel free to contact us if other questions arise.
 
Kind regards,
Nadia

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster April 26, 2022

Hello, Younus,
 
Hope you are doing well.
 
We were wondering if you had a chance to test the server filter.
 
Looking forward to hearing your feedback.
 
Kind regards,
Nadia

Please login or Register to Submit Answer