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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to use a custom SQL function in a DirectQuery/PowerQuery?

Hi

 

In our Power BI dashboard, we want a simple visualization as explained below.

 

The table consists of two columns: a date and the temprature that was measured on that date

A user has to select a time range, being a begin and end date. e.g. 01/01/2022 and 01/01/2023

Next we want to aggregate the temperatures within this range. We are talking about a custom aggregate function that is not one of the standard aggregation functions (like average, median). We want to do something more complex such as calculating the linear regression coefficients.

 

The function to calculate the linear regression coefficients has been implented by us in SQL and is registered in the underlying database. Eventually leading our query to be something like: SELECT linear_regression_coefs(temprature) in MyTable where date > start_date_param AND date end_date_param

 

Now, how am I able to implement this query and use my function in Power BI? 

1 REPLY 1
lbendlin
Super User
Super User

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.