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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
rbermanmw
Frequent Visitor

direct query for mariadb via SQL query to join tables

Hi all,

I am new to Power BI and I am trying to get data to create a power BI report via a direct query to a Maria DB. I have two related tables that I would like to join and then import using a specialized SQL query.  I could import both tables before joining but I don't feel the need to import all the data just to get rid of most of it. Here's an example simplified scenario. I have two tables posts and comments. I would like to load 1 table with the joined data, using the SQL below, rather than the two tables and then joining and processing them:

 

SELECT p.id, p.summary, p.view_count, IF(COUNT(c.id) > 0, 'Commented', 'Uncommented') AS status

FROM posts p

LEFT JOIN comments c

ON c.post_id = p.id

WHERE p.deleted_at IS NULL

GROUP BY p.id

 

I see there is a way to use an SQL query for for direct import for SQL server but I am using MariaDB. Is there a way to do this easily?
2 REPLIES 2
AbhinavJoshi
Responsive Resident
Responsive Resident

Hi @rbermanmw. Go to Power Query Editor ->New Source -> Get Data. In the source select MariaDB. 

AbhinavJoshi_0-1689625522889.png

Enter the credentials 

AbhinavJoshi_1-1689625571239.png

When you load the tables, you will see your SQL query in the formual section, modify that with your desired query and it should work. 

 

@AbhinavJoshi Can you show me a screenshot of the formula section with an SQL query in it?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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