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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
ND_Pard
Helper II
Helper II

Help with using an SQL statement in Power Query to extract data from an Excel workboook

Currrently the M Language in a Power Query that extracts data from a workbook looks like:
let
Source = Excel.Workbook(File.Contents("P:\So Fiscal Administration\Cost Centers\PeopleSoft_Accounts_SAMIS_Object_Codes.xls"), null, true),
Acct_Codes1 = Source{[Name="Acct_Codes"]}[Data]
in
Acct_Codes1

How would I change the above if I wanted to use an SQL statement like the following to extract the data:
Select Acct, Acct_Descr from Acct_Codes

Note: I know I could use the former code and then remove other columns, but I'm curious if I can use the latter code; i.e., can I use an SQL select statement in the top code?

Thanks in advance..

2 REPLIES 2
smpa01
Community Champion
Community Champion

@ND_Pard there is a way. If you have premium workspace, bring your data to datamart and the world of SQL is open to you.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
StefanoGrimaldi
Resident Rockstar
Resident Rockstar

you cant use sql statement on a excel data extraction. 





Did I answer your question? Mark my post as a solution! / Did it help? Give some Kudos!

Proud to be a Super User!




Helpful resources

Announcements
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.