Open chewCheelimdb opened 4 years ago
It depends on what data type the column is. Assuming it's a Date type then probably the following will work. Place this code at the top of your PBIReport.JSON file:
function range(size, startAt) {
return [...Array(size).keys()].map(i => new Date(startAt.valueOf()+i*24*60*60*1000).toISOString().substring(0,10) + " 00:00:00");
}
Then instead of doing a hardcoded filters list like "filtersList":["2018-09-01 00:00:00","2018-09-02 00:00:00", etc......
instead use the range function:
"filtersList":range(16,new Date("2018-09-01"))
If you want a multi-select date range rather than selecting one date in the rage each report render iteration then do:
"filtersList":[
range(16,new Date("2018-09-01")),
range(10,new Date("2019-09-01"))
]
One report rendering iteration would display 2018-09-01 to 2018-09-16 as a multi select. Another would return 2019-09-01 to 2019-09-10.
Basically the PBIReport.JSON file is actually JavaScript code, not just JSON. So you can do whatever you want in terms of code inline.
If your "date" column is really a formatted string, then you will need to customize the range function to format the response as a properly formatted string.
If you want a true “is between” filter then you will have to rework the RealisticLoadTest.html code. The above suggestion will expand out the range into a list of values and pass them in as a multi-select list.
Thanks Greg. Sorry for my late reply. Got caught up with meetings most of yesterday. This is brilliant. When I added the config as you had instructed, it's still neither selecting my date range specified nor crashing the chrome portal. The load test still being executed as -is without selecting the dates range desired. -- See below PBIReport.json sample.
This is not the end of the world for me.
I modified my PBIX by using "month" instead of dates .. then I just reused the same Filter List in Json to iterate through my testing.
However, I encountered a crash, which I think it's the 'memory leak' issue that you commented in code that I read. Is there a way to fix this ?
-- PBIReport.json sample modified with ur suggestion.
`function range(size, startAt) { return [...Array(size).keys()].map(i => new Date(startAt.valueOf()+i2460601000).toISOString().substring(0,10) + " 00:00:00"); }
reportParameters={ "reportUrl":"", "pageName": "ReportSection92b26ef7e329ace69c1e", "bookmarkList": ["Bookmark844da92d993baff200d2"], "sessionRestart":100, "filters": [ { "filterTable":"filter_area_dept", "filterColumn":"sel_dept_name", "isSlicer":true, "filtersList":["ED-All"] } , { "filterTable":"filter_panel_test", "filterColumn":"sel_display_name", "isSlicer":true, "filtersList":["All Tests"] } , { "filterTable":"filter_panel_test", "filterColumn":"sel_metric_name", "isSlicer":true, "filtersList":["Ord-Coll"] }, { "filterTable":"dim_period", "filterColumn":"begin_period_dt", "isSlicer":true, "filtersList":[ range(30,new Date("2018-09-01")), range(10,new Date("2019-01-01")) ] } ], "thinkTimeSeconds":1 } `
I haven’t run into memory leaks and crashes. Is the report extremely complex?
If it refreshes say 3 times and then crashes I suppose you could change sessionRestart to 3 and see if that works around the issue.
You might also ensure that you have the latest .js file downloaded as described here: https://github.com/microsoft/PowerBI-Tools-For-Capacities/issues/10#issuecomment-582734257
And ensure you have the latest Chrome update installed.
Keep us posted.
Greg, Thanks for pointing out that the crashes could be my machine. I requested another dev machine from DevOps team and re-executed same scripts and I was able to execute till token expired. (awesome! )
Thanks again for your guidance! :)
Hi @furmangg , hope you're good! Can I ask you how to set up a number range? How do I set up the function to have a whole number and a range? Thanks!
function range(size, startAt) { return [...Array(size).keys()].map(i => new Date(startAt.valueOf()+i2460601000).toISOString().substring(0,10) + " 00:00:00")
Hi, I need sample json to take in date range as filter values. E.g Begin period date = 2018-09-01 End period date = 2018-09-15