Forum Discussion

vishy4271's avatar
vishy4271
Frequent Visitor
7 years ago
Solved

Dynamic Data Refresh - Power BI Service

We have a requirement wherein the source for the powerbi report is a stored procedure in a database the output data of which needs to be imported in the report monthly.   Issue :. The stored proced...
  • Anonymous's avatar
    Anonymous
    7 years ago

    I have a similar stored procedure where i need to pass along a parameter for start and end dates that i'm calculating in a function. 

     

    So my source line looks like:

    Source = Sql.Database("MyInstance.database.windows.net", "SQL-DW-PROD", [Query="Exec MyDataBase.[sp_MyProcedure] 0, " & fnStartDate & ", " & fnEndDate", HierarchicalNavigation=true, CommandTimeout=#duration(0, 0, 90, 0)])

    Then i have another 2 queries as the functions, named fnStartDate and fnEndDate where i can calculate those exact dates.  They can look as based as this:

     

    let
        Result = "'2016-01-01'"
    in
        Result

    Or you can get more complex and calculate a date like this:

    let
        CurrentMonth = Date.Month(DateTime.LocalNow()),
        CurrentYear = Date.Year(DateTime.LocalNow()),    
        Result = Number.ToText(CurrentYear) & "-" & Number.ToText(CurrentMonth) & "-03"
    in
        Result