How can we show previous 12 month on selecting a particular month in filter
Hi harikm007 ,
I want to show previous 12 months of data from a selection I make on a month filter. But the user should be able to change the month and the previous 12 month will get updated based on the selection
For e.g. If I select Dec-2022 then the column chart should show bars from Jan-2022 to Dec-2022.
If I select March-2022 then the column chart should show bars from April-2021 to March-2022.
Regards,
Rahul
Hello rahuldhomane ,
You can try below widget script to display previous 12 months of data from selected month. Here update the variable 'monthFilterName' with name of your filter.
widget.on("beforequery", function(se,ev) { var monthFilterName = "Months in Date of Joining"; var numberofPrevMonths = 10 monthFilter = ev.query.metadata.find(el => el.jaql.title == monthFilterName && el.panel == 'scope') if(monthFilter) { prevMonth = new Date(monthFilter.jaql.filter.members[0]) for(i = 1; i < numberofPrevMonths; i++) { prevMonth = new Date(prevMonth.setMonth(prevMonth.getMonth()-1)) preMonthStr = prevMonth.getFullYear() + '-' + ('0' + (prevMonth.getMonth()+1)).slice(-2) + "-01T00:00:00" //prevMonth.toISOString(); monthFilter.jaql.filter.members.unshift(preMonthStr) } } });
Also if you add Date Range Slider plugin, it will give you an option to select any date range in addition to previous 12 months.
Please let me know if you have any questions
Always here to help,
Harry from QBeeQ
[email protected]
QBeeQ - Gold Implementation and Development Partner
www.qbeeq.pl