Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Passing start and end date for 'between'-slicer in URL?

Hello,

 

I'm trying to embed a report in a confluence page. It's supposed to filter the three months before a month that is defined in the page. So if the page is for Febuary 2023, the embedded report should show 11-2022, 12-2022 and 01-2023. I have no problem to configure a filter that shows the correct range for months after march, e.g. with this line:

 

Date/Year eq 2023 and Date/Month ge 9 and and Date/Month le 11

 

but this oviously wont work with the first three months. I tried to configure a slicer with the "between" option, but I can't seem to pass the correct start and end timestamp within the URL, e.g. like this:

 

&$filter=SlicerX/Date ge 2023-05-01 and SlicerX/Date lt 2023-08-01

 

I read Filter a report using query string parameters in the URL - Power BI | Microsoft Learn, but can't find a solution.

 

I'm wondering if it's even possible to achieve what I'm trying to do.

 

Any help is appreciated.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I just figured out that I asked the wrong question. The 

 

Date/Year, Date/Month etc.

 

parts in the URL-filter refer to a table in the query and a column inside that table. I didn't know that until today and since I have a "Date" column in my "Date" table, I could easily solve this by building the filter like this:

 

$filter=Date/Date ge " + startYear + "-" + startMonthStr + "-01 and Date/Date lt " + endYear + "-" + endMonthStr + "-01"

 

If anyone ever encounters a similar problem, here is the whole script:

 

<script>
document.addEventListener("DOMContentLoaded", function() {
var pageTitle = document.title;
var match = pageTitle.match(/\((\d{2})-(\d{4})\)/);
if (match) {
var month = parseInt(match[1]);
var year = parseInt(match[2]);               
var startYear = year;
var startMonth = month - 3;
var endYear = year;
var endMonth = month;

if (startMonth <= 0) {
startMonth = startMonth + 12;
startYear--;
}
var startMonthStr = startMonth < 10 ? "0" + startMonth : startMonth;
var endMonthStr = endMonth < 10 ? "0" + endMonth : endMonth;

       var dynamicURL = "https://app.powerbi.com/reportEmbed?reportId=XXX&appId=XXX&autoAuth=true&ctid=XXX&navContentPaneEnabled=false&pageName=ReportSectionXXX&$filter=Date/Date ge " + startYear + "-" + startMonthStr + "-01 and Date/Date lt " + endYear + "-" + endMonthStr + "-01";                      
document.getElementById("dashboardIframe").src=dynamicURL;
}
});
</script>
<body>
<iframe id="dashboardIframe" title="Title" width="500" height="1500"></iframe>
</body>

 

This script loads when the rest of the page is loaded (the EventListener does that) and creates the URL of an embedded PowerBI report from a string in the document title that consists of month and year (e.g. 02-2024). 

 

There might be a smarter way, idk, but this works. Replace XXX in the URL with the IDs of your report, delete all date-filters in the report you want to filter while embedded, put the code in an html-box in confluence (if available, might need to ask admin) and it should work.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

I just figured out that I asked the wrong question. The 

 

Date/Year, Date/Month etc.

 

parts in the URL-filter refer to a table in the query and a column inside that table. I didn't know that until today and since I have a "Date" column in my "Date" table, I could easily solve this by building the filter like this:

 

$filter=Date/Date ge " + startYear + "-" + startMonthStr + "-01 and Date/Date lt " + endYear + "-" + endMonthStr + "-01"

 

If anyone ever encounters a similar problem, here is the whole script:

 

<script>
document.addEventListener("DOMContentLoaded", function() {
var pageTitle = document.title;
var match = pageTitle.match(/\((\d{2})-(\d{4})\)/);
if (match) {
var month = parseInt(match[1]);
var year = parseInt(match[2]);               
var startYear = year;
var startMonth = month - 3;
var endYear = year;
var endMonth = month;

if (startMonth <= 0) {
startMonth = startMonth + 12;
startYear--;
}
var startMonthStr = startMonth < 10 ? "0" + startMonth : startMonth;
var endMonthStr = endMonth < 10 ? "0" + endMonth : endMonth;

       var dynamicURL = "https://app.powerbi.com/reportEmbed?reportId=XXX&appId=XXX&autoAuth=true&ctid=XXX&navContentPaneEnabled=false&pageName=ReportSectionXXX&$filter=Date/Date ge " + startYear + "-" + startMonthStr + "-01 and Date/Date lt " + endYear + "-" + endMonthStr + "-01";                      
document.getElementById("dashboardIframe").src=dynamicURL;
}
});
</script>
<body>
<iframe id="dashboardIframe" title="Title" width="500" height="1500"></iframe>
</body>

 

This script loads when the rest of the page is loaded (the EventListener does that) and creates the URL of an embedded PowerBI report from a string in the document title that consists of month and year (e.g. 02-2024). 

 

There might be a smarter way, idk, but this works. Replace XXX in the URL with the IDs of your report, delete all date-filters in the report you want to filter while embedded, put the code in an html-box in confluence (if available, might need to ask admin) and it should work.

lbendlin
Super User
Super User

Not possible. You may need to enumerate all the desired date values.

 

URL filters affect the semantic model, not the slicer.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors