Power BI reporting is a great way to display large amounts of data using out-of-the-box charts and widgets. All these chart and widgets provide a lot of features like drill down, filter based on click, export, etc. But since Power BI is a reporting tool, we tend to come across a lot of data and often we would like to see data for a specific date range to start with.
Knowledge of Power BI report and Date Slicer
Knowledge on any server-side technology. For this article we will be using C#.
Step 1:In the first step, we will be setting up the Date slicer on Power BI side. Let’s say we have a “DimCustomer” table and a “Date” field. We would set up the date slicer using the same, not other setting required. We have not set up a relative date range filter.
We are not going into details of embedding. All the details can be found in the above link.
Step 3: Once the code is ready and the report is embedded, we can move on to the next step. We are going to set two dates from date and to date in C#. We want to see data for 3, so we are going to set up -90 in the AddDays function.
Step 5: The last step is to pass the new filters to config object as below:
We are all done, so we should be able to see the date, right? But it’s strange: The date is still not reflected as expected. So, after some more digging we found that the date needs to be entered in a specific format, only then will it show up in reports.
There we go. Now, we can set up any date range period on the Date Slicer. To change the date period, all we need to do is to set up the desired from date and to date using C# and the same would be set up in Power BI.