Forum Discussion

andyor's avatar
andyor
Resolver I
3 years ago
Solved

Importing Stored Procedure + Dynamic Date Parameter

I'm new to to Power BI and I've been researching how to import Stored Procedure's from Get Data query in PBI and someone said that the easiest way is to Execute in SQL Server, then copy in the execut...
  • andyor's avatar
    3 years ago

    The solution is to declare and set these in the import statement E.g., 

     

     

    DECLARE	@return_value int
    DECLARE @start datetime
    DECLARE @end datetime
    
    SET @start = DATEADD(Day, 0, DATEDIFF(Day, 0, GetDate()))
    SET @end = getdate()
    
    EXEC	@return_value = [Reporting].[XXXXX]
    		@TimeZoneID = 1,
    		@TZStartDate = @start,
    		@TZEndDate = @end,
    		@DateType = 3
    
    SELECT	'Return Value' = @return_value