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
inspirz
New Member

Advanced Editor from SQL Database

Hi,

 

I created a Direct Query to a SQl database to bring in production rate information. When I click "Get Data" and then select the SQL table and right click and then I choose "Edit" and then select "Advanced Editor" which brings up a pop-up with SQL'ish type language (please see below, edited of course). In that SQl table is a column called "Stream IDs" and I want to create a query to bring in specific "Stream IDs" and not all of them? Could someone please let me know how to do that? In SQL I would have simply wrote "... where Stream_IDs = '1' or Stream_IDs = '2' and et cetera...

 

let
    Source = Sql.Databases("servername"),
    servername2 = Source{[Name="servername2"]}[Data],
    dbo__table_name = servername2{[Schema="dbo",Item="_table_name"]}[Data]
in
    dbo_table_name

1 ACCEPTED SOLUTION

this is where you will put your query:

 

q.PNG



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

10 REPLIES 10
MFelix
Super User
Super User

Hi @inspirz,

 

can test this out but believe tha you can select the direct query and then the advance options you can write your SQL statement like you would:

 

Select 

    StreamID,

    Description

From

    Table

Where

    StreamID = 1 or StreamID = 2

 

Regards,

Mfelix

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



ok that didn't work....

what didn't work? What error you are getting? Make sure to enter your "sql server name" in server.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks a lot. I'm new to all this but I thought in Power BI Advanced Editor the power Query language had to be structured with "let" and "in" and not "select" "from" "where" but I'll try it out.

this is where you will put your query:

 

q.PNG



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k

I was wondering if might know these answers. At the bottom of SQL Statement box, do you know what the exact meaning/purpose is for each of those check marks?

"Include relationship columns"

"Navigate using full hierarchy"

"Enable SQl Server Failover support"

Thanks. That worked. I feel like an idiot now.

parry2k
Super User
Super User

The better approach would be to create a view in you sql db and use that view, although what you mentioned here can still be achieved.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

The DB admin won't create that view because she's worried we'd have a million views for various people.

inspirz
New Member

Hi,

 

I created a DIRECT QUERY to a SQL database to bring in large amounts of refinery production rate data. I want the query only to bring in certain stream id's and not show all the steam id's. So, when I click "Get Data" select the SQL table and rt click it I get an "Edit" option and it brings up the "Query Editor" and when I click "Advanced Editor" I get a window that looks like quasi-SQL language (please see below). In the table is a column called "Stream IDs" and I want to write into the query so it brings back only Stream Ids "1,2,3,4,5,6" abd et cetera. How do I write that?

 

let
    Source = Sql.Databases("server_name"),
    Servername2 = Source{[Name="Servername2"]}[Data],
    dbo_table_name = Servername2{[Schema="dbo",Item="dbo_table_name"]}[Data]
in
    dbo_table_name

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.