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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
markefrody
Post Patron
Post Patron

Importing Table-Valued Function in SQL to Power BI

Hi,

 

I have table-valued function in SQL that I wish to import in Power BI. Problem is I cannot directly import the entire table-valued function to Power BI. It prompts me to input the start and end date, which will make my data static.

 

Import Data.png

The table-valued function in SQL is a bit complicated. Table-valued function name: dbo.EquipmentStatusDuration

The table-valued function works wherein when it takes two parameters “StatusChangeDateFinal” and “StatusDateFinal” into consideration.


For example if I used Feb 21,2019 (02-21-2019) and March 3,2019 (03-05-2019) as my search parameters. It will display all entries wherein these dates fall into:

Sample 1.png

It will then compute, the minutes (SegmentMinutes) and second (SegmentSeconds) per each of the entry for the Feb 21, 2019 to March 3, 2019 dates ONLY. It will disregard the date prior or after dates.

For example: if I used Feb 21,2019 (02-21-2019) and March 3,2019 (03-05-2019) it will show the below results. We will use the below circled entry:
Sample 2 edited.jpg

In the highlighted row entry, the date range of ONLY Feb 21, 2019 to March 3, 2019 is taken into consideration. It does not include dates before Feb 21, 2019 and dates after March 3, 2019. It will only calculate the number of minutes and seconds for date range of ONLY Feb 21, 2019 to March 3, 2019.

Please let me know if this function is possible to be imported by Power BI using the same logic used in the table-valued fuction in SQL? Appreciate your kind response. Thanks.


P.S.

Not sure if this will help, but below is the SQL code used to run the query:
SELECT EquipmentIdentifier, VehicleType, Year, MFGName, ModelName, StatusChangeDateFinal, StatusDateEnd, StatusEnd, SegmentMinutes, SegmentSeconds
FROM dbo.EquipmentStatusDuration('02-21-2019', '03-05-2019') AS EquipmentStatusDuration_1
WHERE (StatusEnd = N'In Service')

1 ACCEPTED SOLUTION
venal
Memorable Member
Memorable Member

@markefrody 

I tried to re-pro the issue from my end and it is showing that static, no option to change the input parameters.

 

I tried two ways, 

 

1. After selecting the function, passed the input parameter values before loading.

2. By using the "Advanced Options", copied the function select statement.

SELECT * FROM DBO.EMPHIREDATE('01/01/1981','12/31/1981')

 

Hoping that this is be design now, Please post your idea in "Power BI Ideas Forum Page".

 

If this post helps, then please consider Accept it as the solution to help the other members find it more
If this post was helpful may I ask you to mark it as solution and click on thumb symbol?

View solution in original post

4 REPLIES 4
otiliagaino
Helper I
Helper I

Hi, can anyone be of some help looking at my current issue with dynamic parameters to table valued functions. Everything is described at https://community.fabric.microsoft.com/t5/Power-Query/Power-Query-Date-Parameter-Binding-to-my-Direc....

Any help would be really appreciated!! Thanks in advance

venal
Memorable Member
Memorable Member

@markefrody 

I tried to re-pro the issue from my end and it is showing that static, no option to change the input parameters.

 

I tried two ways, 

 

1. After selecting the function, passed the input parameter values before loading.

2. By using the "Advanced Options", copied the function select statement.

SELECT * FROM DBO.EMPHIREDATE('01/01/1981','12/31/1981')

 

Hoping that this is be design now, Please post your idea in "Power BI Ideas Forum Page".

 

If this post helps, then please consider Accept it as the solution to help the other members find it more
If this post was helpful may I ask you to mark it as solution and click on thumb symbol?

Has this issue been fixed?  I am at a loss as to why this and others have been marked as "solved" with no viable solutions noted. 😕

Thanks for checking @venal. I'll probably replicate how the table-valued function is constructed in SQL to Power BI. 

Thank you again for your support.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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