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
Hussard
Frequent Visitor

SQL Query to Power BI

Hi all,

 

At first I made a view in SQL SERVER, and all is OK.

 

Now I want to create directly into Power BI the same query I've done in SQL Server but from the whole tables.

 

Here is the SQL statement:

 

SELECT pc.id ,count(*) cpt, p.state
FROM Product AS p INNER JOIN Prices AS pp ON p.Id = pp.IdProduct INNER JOIN Catalog AS pc ON p.IdCatalog = pc.Id
WHERE ISNULL(pp.tariff, 0) <> 1 AND pc.version<> - 1 and pc.Status<>2
group by pc.id, p.state
order by pc.id

 

I tried to merge queries in query editor and also create some fields but ... I don't know what is the best method to do that.

 

I think this issue is quite easy to solve but I don't know how.

 

Thanks !

 

Sébastien

1 ACCEPTED SOLUTION

DirectQuery is not the best mode to get to know Power BI. It is better to work with Import in this case.

 

How to implement such task via Power BI:

1. Go to an advanced editor of a blank query.

2. Reference the first table and filter it as you mentioned in SQL:

    ISNULL(pp.tariff, 0) <> 1 AND pc.version<> - 1 and pc.Status<>2

3. Repeat the previous action to last two tables.

4. Use merge to join 1st and 2nd.

5. Merge result of the previous action with 3rd.

6. Do grouping

7. Do ordering

 

Regards,

Ruslan

View solution in original post

10 REPLIES 10

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.