Share this
Using JavaScript For Power BI Filters in PBRS
by Steven Amani on Sep 24, 2020 12:06:40 PM
One of the most useful features of PowerBI Reports is the ability to set report-level filters so that the information displayed within it can be relevant to the consumer.
What are Filters in Power BI?
Filters in Power BI distill and sort data and information based on a selected criteria. That is, you can select particular fields or values within fields and view only the information related to that. For instance, if you have a dataset related to sales of a store, you can use Filters to view a report having only the data for the selected aspects.
For example, if you only want to see the sales information in the Charlotte area in the year 2019, all you have to do is to put the filtering criterion as 2019 and Charlotte in their respective fields. The report of sales will immediately make changes accordingly and only show the graphs and visuals specific to sales statistics in Charlotte and in the year 2019.
How Does PBRS Support Report-Level Power BI Filters?
PBRS has always supported passing report-level Filters to Power BI reports so that when the report is automatically generated, it is delivered with just the right information. In fact, PBRS users love using Data-Driven subscription schedules to run multiple instances of Power BI reports, with filters configured via the data-driver and then delivered to data driven recipients, the resulting exported output file containing only the information relevant to the recipient.
One challenge that has always plagued the more advanced user, however, is when a Power BI report contains more than a couple of filters to configure. As the number of report filters increases, the process of setting up the PBRS schedule quickly becomes tedious and prone to errors.
In the September 2020 release of PBRS, we addressed this problem by allowing our advanced users to configure their Power BI Filters via JavaScript.
Using Javascript To Configure PBRS Filters
Instead of spending a long time manually entering a single filter at a time, PBRS users can now simply write the JavaScript function in their favorite code editor (or in PBRS itself) and then save it as part of the schedule. Furthermore, the JavaScript function can be stored in the end user’s database and pulled into the schedule using a data-driver insert.
How to Construct Power BI Filters With JavaScript
Microsoft has detailed information on how to create Filter objects in JavaScript and this can be found here:
https://github.com/Microsoft/PowerBI-JavaScript/wiki/Filters#contructingfilters
Once the filters have been created, the only requirement from PBRS is that it is placed inside a JavaScript function that returns an array of all the filters. An example of this can be seen below.
Function getFilters(){
let basicCustomerFilter = …..;
let advancedRegionFilter = ……;
let employeesFilter = …..;
return [basicCompanyFilter, advancedRegionFilter, employeesFilter]
}
In order to streamline the creation of the filter function for PBRS data-driven schedules, it is recommended to build a SQL function or Stored Procedure that accepts a key identifier and returns the full function. This is so that all the logic can be changed in one place and doesn’t have to be created in an inline SQL query.
For example:
SELECT dbo.Custumer.CustomerId, dbo.Customer.EmailAddress, dbo.GetPowerBiFilterFunction(Customer.CustomerId) AS PowerBiFilter FROM dbo.Customer
With this query as the data-driver, the PowerBi Filter column can simply be dropped into the Filter JavaScript field.
Let us know if you have any questions or suggestions about this feature.
Tutorial: Data Driven Subscription Scheduling for Power BI
Share this
- Business Intelligence (174)
- PBRS (172)
- Power BI Reports (153)
- Power BI (152)
- Power BI Reports Scheduler (151)
- IntelliFront BI (113)
- Microsoft Power BI (103)
- Dashboards (81)
- Data Analytics (80)
- Data Analytics Software (80)
- Business Intelligence Tools (79)
- Data Analytics Tools (79)
- Reports (79)
- KPI (77)
- SSRS (33)
- Crystal Reports (29)
- Crystal Reports Scheduler (28)
- SSRS Reports (25)
- SSRS Reports Scheduler (25)
- SSRS Reports Automation (23)
- CRD (20)
- Tutorial (8)
- Crystal Reports Server (6)
- Power BI to CSV (6)
- Power BI to Excel (6)
- ChristianSteven (3)
- KPIs (3)
- ATRS (2)
- Bi dashboard (2)
- Business Analytics (2)
- KPI software (2)
- Self-Service Data Analytics Tools (2)
- Tableau (2)
- Tableau Report Automation (2)
- Tableau Report Export (2)
- Tableau Report Scheduler (2)
- bi dashboard solution (2)
- business intelligence reports (2)
- business intelligence software (2)
- data analytics solutions (2)
- key performance indicators (2)
- power bi email subscriptions (2)
- Data Driven Schedules (1)
- GH1 (1)
- Power BI Dashboards (1)
- Reporting (1)
- Static Power BI Report (1)
- automation in power bi (1)
- benefits of automation in power BI (1)
- bi data (1)
- bi roi (1)
- business intelligence for finance department (1)
- business intelligence implementation challenges (1)
- construct bi reports with power bi (1)
- construction bi (1)
- crystal reports software (1)
- crysyal reports distribution (1)
- data analytics business intelligence difference (1)
- data analytics product (1)
- data analytics techniques (1)
- distribute power bi report (1)
- email power bi (1)
- enterprise bi server (1)
- enterprise bi software (1)
- hospital business intelligence (1)
- incisive analytics (1)
- intuitive business intelligence (1)
- power BI exporting (1)
- power bi emails to share reports (1)
- power bi for construction project (1)
- power bi healthcare (1)
- print power bi report (1)
- real estate business intelligence (1)
- schedule power bi (1)
- schedule power bi reports (1)
- scheduled power bi emails (1)
- scheduling Power BI reports (1)
- share power BI reports by email (1)
- share power bi reports (1)
- share your Power BI reports as PDF (1)
- tools for business intelligence (1)
- use drop box to share Power BI Reports (1)
- October 2024 (1)
- September 2024 (1)
- April 2024 (1)
- March 2024 (1)
- February 2024 (1)
- January 2024 (1)
- December 2023 (1)
- November 2023 (1)
- October 2023 (2)
- September 2023 (1)
- August 2023 (1)
- July 2023 (1)
- June 2023 (1)
- May 2023 (1)
- April 2023 (1)
- March 2023 (1)
- February 2023 (1)
- January 2023 (1)
- December 2022 (1)
- November 2022 (1)
- October 2022 (1)
- September 2022 (1)
- August 2022 (1)
- July 2022 (1)
- June 2022 (1)
- May 2022 (1)
- April 2022 (1)
- March 2022 (1)
- February 2022 (1)
- January 2022 (1)
- December 2021 (1)
- November 2021 (1)
- October 2021 (2)
- September 2021 (1)
- August 2021 (2)
- July 2021 (1)
- June 2021 (4)
- May 2021 (5)
- April 2021 (3)
- March 2021 (2)
- February 2021 (2)
- January 2021 (2)
- December 2020 (2)
- November 2020 (2)
- September 2020 (8)
- August 2020 (3)
- July 2020 (5)
- June 2020 (12)
- May 2020 (2)
- April 2020 (3)
- March 2020 (2)
- February 2020 (5)
- January 2020 (7)
- December 2019 (9)
- November 2019 (9)
- October 2019 (10)
- September 2019 (5)
- August 2019 (6)
- July 2019 (13)
- June 2019 (8)
- May 2019 (3)
- April 2019 (5)
- March 2019 (4)
- February 2019 (3)
- January 2019 (10)
- December 2018 (2)
- November 2018 (22)
- October 2018 (10)
- September 2018 (12)
- August 2018 (5)
- July 2018 (23)
- June 2018 (29)
- May 2018 (25)
- April 2018 (12)
- March 2018 (22)
- February 2018 (15)
- January 2018 (15)
- December 2017 (6)
- November 2017 (4)
- October 2017 (4)
- September 2017 (4)
- August 2017 (4)
- July 2017 (7)
- June 2017 (12)
- May 2017 (10)
- April 2017 (6)
- March 2017 (10)
- February 2017 (7)
- January 2017 (5)
No Comments Yet
Let us know what you think