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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mnawaz
Regular Visitor

Changing from Stored Procedure based Source with Import Data to a Table/View

I am having issues when trying to change the Source from a Stored Procedure based to a Table or a view. I don't get the navigation page to select the table/view after changing the source and removing the Stored Procedure from the SQL Statement Box.

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

this is not as simple as one might want it to be, but nevertheless it's possible with a little adjusting of the generated M code using the Advanced Editor in Power Query.

The following shows the M code from the Advanced Editor, the query is using a stored procedure to return some data:

let
    Source = Sql.Database("mycomputername\sqlserver2017", "wideworldimportersdw", [Query="execute dbo.a_simple_select"])
in
    Source

Another important thing to notice is that there is no Navigation step.

 

Now if you create another connection to the same database and now you use the object navigation (meaning selecting one of the available tables or views, the M code will look like this:

let
    Source = Sql.Database("mycomputername\sqlserver2017", "wideworldimportersdw"),
    Fact_Sale = Source{[Schema="Fact",Item="Sale"]}[Data]
in
    Fact_Sale

Basically it's possible to adjust the Source line from the 1st query and add a 2nd line that does the navigation like so:

let
    //Source = Sql.Database("mycomputername\sqlserver2017", "wideworldimportersdw", [Query="execute dbo.a_simple_select"])
    Source = Sql.Database("mycomputername\sqlserver2017", "wideworldimportersdw"),
    Fact_Sale = Source{[Schema="Fact",Item="Sale"]}[Data]
in
    Fact_Sale

After this adjustment, the 1st query also has a Navigation step. Please make sure that the object returns the same column names as they have been returned by the stored procedure, otherwise your visuals will break.

 

I urge you to try this in a copy of a working Power BI Desktop file, as things might break

 

Hopefully this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Hey,

 

this is not as simple as one might want it to be, but nevertheless it's possible with a little adjusting of the generated M code using the Advanced Editor in Power Query.

The following shows the M code from the Advanced Editor, the query is using a stored procedure to return some data:

let
    Source = Sql.Database("mycomputername\sqlserver2017", "wideworldimportersdw", [Query="execute dbo.a_simple_select"])
in
    Source

Another important thing to notice is that there is no Navigation step.

 

Now if you create another connection to the same database and now you use the object navigation (meaning selecting one of the available tables or views, the M code will look like this:

let
    Source = Sql.Database("mycomputername\sqlserver2017", "wideworldimportersdw"),
    Fact_Sale = Source{[Schema="Fact",Item="Sale"]}[Data]
in
    Fact_Sale

Basically it's possible to adjust the Source line from the 1st query and add a 2nd line that does the navigation like so:

let
    //Source = Sql.Database("mycomputername\sqlserver2017", "wideworldimportersdw", [Query="execute dbo.a_simple_select"])
    Source = Sql.Database("mycomputername\sqlserver2017", "wideworldimportersdw"),
    Fact_Sale = Source{[Schema="Fact",Item="Sale"]}[Data]
in
    Fact_Sale

After this adjustment, the 1st query also has a Navigation step. Please make sure that the object returns the same column names as they have been returned by the stored procedure, otherwise your visuals will break.

 

I urge you to try this in a copy of a working Power BI Desktop file, as things might break

 

Hopefully this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thanks Tom, that solution worked. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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