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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
MarkHoughton
Regular Visitor

Direct Query SQL table fails to import even though it previews correctly

Hi, I am new to PowerBI and just finding my way around. I have imported using direct query a number of tables and pull through financial information ok. However, I am attempting to build a department heirarchy and failing. In my SQL database I have 2 tables, one with the dept id and dept description, the other table has two columns, one id is the matched dept id, the other id is its parent id. I have a sql script which pulls the names in so that i have 4 columns, Parent Name, Parent Id, ChildDept Id, ChildDept Name. All well and good and it displays ok in the query editor when attempting to import.

 

SqlDeptTree.JPG

 

However, it will not allow me to 'accept' the query. I get this error.SqlDeptTree2.JPG

I don't know why if it previews the source ok that it fails to 'accept' it.

What am i doing wrong ?

 

Thanks

Mark

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

Can you post the SQL you are using?

 

One nit-pick, when you use Direct Query, you are technically not "importing" anything.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi,

 

I know it's not importing, but I don't know what other term to use and to my mind because I am merging 2 different tables then I feel like I am 'importing'. Anyway....

 

Here is the script

 

select Dept2.[MEM_DESC] as 'Parent Dept',Dept2.MEM_ID as 'Parent Id',Dept1.MEM_ID as 'Dept Id', Dept1.[MEM_DESC] as 'Child Dept' from [CLIVE].[CLIVE].[CUST1] Dept1 inner join [CLIVE].[CLIVE].[CUST1_TREE]  DeptTree on Dept1.MEM_ID=DeptTree.MEM_ID inner join [CLIVE].[CLIVE].[CUST1] Dept2 on Dept2.MEM_ID=DeptTree.MEM_PID

Hi, yes, when i enter the query in SQL managament studio the tables are merged as I expect, it displays the same results as the BI preview.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.