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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Shawn_Eary
Advocate V
Advocate V

Run SQL Query Against Imported CSV

Does Power BI allow you to run SQL Queries against data imported from CSV?

I think I can do this to a limited extent in:

  1. MS Excel
    (Not sure how easy it is to query across multiple related tables and do nested queries)
  2. Rainbow CSV for Visual Studio Code
    (Can query across multiple tables, but I don't think nested queries are supported and the editor TextBox is only one line)
  3. Ben-Attia's Q [https://github.com/harelba/q]
    (There is no Intellisense and running the queries from the GNU\Linux or MS Windows command line is a bit cumbersome. Would be nice if there was a Visual Studio Code or EMACS extension to take formatted SQL and pass it to the Windows or GNU\Linux command line for processing by Ben-Attia's Q)
  4. Yuki's csvq
    (There is an EMACS extension for this, but I'm not sure how easy multiple table joins are)
  5. R
    (I'm not sure how user friendly this will be, and I don't want to mess with a data frame. Also, I don't R Studio license is budget approved, so I probably wouldn't get an IDE)

Without any of the above tools/techniques, I'm stuck importing these CSV files into an MS SQL Server Express instance and using Azure Data Studio to run the queries.

The best option I've seen above (without going full blown SQL Server Express) is Ben-Attia's Q, but it would be really nice if Power BI would provide an easy way for me to query my data besides DAX. Additionally an IDE (with Intellisense) like what is provided in Azure Data Studio and/or MS SQL Server Management Studio would be extremely helpful.

See Also:
[1] - https://softwarerecs.stackexchange.com/questions/61396/is-there-a-software-tool-which-allows-to-perf...

1 ACCEPTED SOLUTION
trebgatte
Most Valuable Professional
Most Valuable Professional

Essentially, once you import your CSV data imported into PBI, it is stored in an Analysis Service Tabular model within PBI. From there you can use Power Query to do your data transformations. No need to go to any other DB tools.

 

From the main window, click Transform Data in the ribbon to access the Query Editor. 

 

What is Power Query? - Power Query | Microsoft Learn

View solution in original post

4 REPLIES 4
Shawn_Eary
Advocate V
Advocate V

Thanks @trebgatte . I understand the official position, but I'm getting some hard to duplicate aggregation oddities when using two related tables inside a single graphical visualization.

I need to run some SQL Queries as a sanity check. I know a little DAX, but DAX and Power Query seem far less intuitive to me than SQL.

trebgatte
Most Valuable Professional
Most Valuable Professional

If you know SQL, Power Query is a breeze! The editor only loads the first 1000 records. What sort of sanity checks are you attempting?

Unfortunately, I can't be specific right now, but I need to diagnose anomalies similar to this:
https://community.powerbi.com/t5/Desktop/Multiple-Table-Relationships-with-the-Stacked-Column-Chart/...
Only using larger and more complex data sets.

The example provided in the above thread is hypothetical. It attempts to describe just one of the misunderstandings I am having with Power BI when using multiple related tables.

My presumption is that I just don't understand Power BI enough to realize why I am getting strange "answers". Unfortunately, I can't give a visualization to my customer if I designed that visualization incorrectly and it returns insane results. I want to use SQL (which I'm more experienced with) to verify that I'm on the right track.

Thanks again!!!

trebgatte
Most Valuable Professional
Most Valuable Professional

Essentially, once you import your CSV data imported into PBI, it is stored in an Analysis Service Tabular model within PBI. From there you can use Power Query to do your data transformations. No need to go to any other DB tools.

 

From the main window, click Transform Data in the ribbon to access the Query Editor. 

 

What is Power Query? - Power Query | Microsoft Learn

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.