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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Direct Query and Native Query

Hi Experts,

I'm connecting to an Azure SQL Server database in Direct Query Mode:

 

SS1.png

 

Then, I'm creating SQL sentences to import the tables with Value.NativeQuery:

 

let
   Source = Value.NativeQuery(#"SQL/mydatabase database windows net;mydatabsae","

	SELECT *
      
FROM TABLEA A
INNER JOIN TABLEB ln on ln.KEY =  A.Key
INNER JOIN TABLEC gc on gc.id =  A.Key

	   ")
in
Source

 

 

Then, I create all the relations between the tables in order to create my Star model. When I create the report, it is not working as I can not see the data, instead I've got this error:

 

Screenshot_1.png

 

Is it because the value.nativeQuery() statement? 

Is it possible to create a model with relations between tables and creating my own querys to combine data with Direct Query On?

Is it strictly necessary to use composite models? I've been reading the documentation and I just want to be sure about it.

I am working with compatibility level: SQL Server 2017 / Azure Analysis Services (1400)

 

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

There is a trick that worked to me: 

 

-First of all, you need to create your model with the property "Direct Query Mode: Off".

-Then, If you want to create your own query, it is necessary to use Sql.Database()

let
   Source = Sql.Database("MyConection", "DATABASE", [Query="
select * from your_table 
.......
	   "])
in
Source

 -Once you import tables and create all relations between them, switch to "Direct Query Mode: On"

 

That's it... it should work!

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

There is a trick that worked to me: 

 

-First of all, you need to create your model with the property "Direct Query Mode: Off".

-Then, If you want to create your own query, it is necessary to use Sql.Database()

let
   Source = Sql.Database("MyConection", "DATABASE", [Query="
select * from your_table 
.......
	   "])
in
Source

 -Once you import tables and create all relations between them, switch to "Direct Query Mode: On"

 

That's it... it should work!

lbendlin
Super User
Super User

I would think that using Value.NativeQuery() will prevent query folding from working - which makes Direct Query a bit pointless.  

 

Try loading your three tables independently and then let the DAX data model do the joins for you.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.