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
chelsweigandt
Regular Visitor

SQL Statement Translation to Power Query

I have this SQL query that has two statements in it. The first statement is straight forward but then it's separated by an OR to the second statement that has an AND statement in it. I can't figure out how to translate this into the Power Query without PBI combining the statements.

 

Here is the original SQL statement: 

select I.INVENTORYID, I.SKU, b.BRANDNAME, I.MPN, I.SHORTDESCRIPTION, I.BINLOCATION, I.INSTOCK, I.INACTIVE
from inventory i inner join brands b on i.BRANDID = b.brandid
where isnull(i.INSTOCK,0) <> 0
or (i.BINLOCATION is not null and isnull(i.INACTIVE,0) = 0)
order by i.BINLOCATION, i.SKU

 

The or & and that are bolded and underlined are what I am having issues with.

 

Can you help me with understanding how to do these statements in PBI.

Thanks!

 

 

1 ACCEPTED SOLUTION

Hi @chelsweigandt ,

 

If you want to do the steps in Query Editor after getting the data, you can follow this:

https://powerbi.microsoft.com/en-us/blog/pull-data-from-sql-server-with-power-bi-designer/

 

I would appreciate Kudos if my response was helpful. I would also appreciate it if you would Mark this As a Solution if it solved the problem. Thanks!

 

 




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

Proud to be a Datanaut!
Private message me for consulting or training needs.




View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@chelsweigandt - Can you not just used the Advanced mode of the SQL connector to just paste in your SQL code?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  when I do that, I get this error

error.PNG

 

 

Hi @chelsweigandt ,

 

If you want to do the steps in Query Editor after getting the data, you can follow this:

https://powerbi.microsoft.com/en-us/blog/pull-data-from-sql-server-with-power-bi-designer/

 

I would appreciate Kudos if my response was helpful. I would also appreciate it if you would Mark this As a Solution if it solved the problem. Thanks!

 

 




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

Proud to be a Datanaut!
Private message me for consulting or training needs.




@collinq That worked! Thanks so much! I had to take out the last bit of the SQL statement (order by i.BINLOCATION, i.SKU) but once I did that it, it worked perfectly. Thanks so much

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.