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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

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
Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.