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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
HamidBee
Impactful Individual
Impactful Individual

Error: This step results in a query that is not supported in DirectQuery mode.

I have the following query that I used to connect to a data source in SQL:

 

 

 

 

SELECT OID.OrderID,O.OrderDate,UnitPrice*Quantity AS Total 
FROM Orders As O
FULL OUTER JOIN [Order Details] AS OID
ON O.OrderID = OID.OrderID

 

 

 

 

I used the DirectQuery method. I then tried to perform a filter between two date ranges. However, when I did this I received an error reading:

 

"This step results in a query that is not supported in DirectQuery mode."

 

Here is the M query:

 

 

 

 

let 
    Source = Sql.Database("(localdb)\Local", "Northwind", [Query="SELECT OID.OrderID,O.OrderDate,UnitPrice*Quantity AS Total#(lf)FROM Orders As O#(lf)INNER JOIN [Order Details] AS OID#(lf)ON O.OrderID = OID.OrderID"]),
    #"Filtered Rows" = Table.SelectRows(Source, each [OrderDate] > #datetime(1996, 1, 1, 0, 0, 0))
in
    #"Filtered Rows"

 

 

 

 

I'm not sure why this is happening and how to fix it. Any help would be greatly appreciated. 

1 ACCEPTED SOLUTION
HamidBee
Impactful Individual
Impactful Individual

I was able to fix the following by firstly using Import mode instead of DirectQuery. Here are the full steps I followed:

HamidBee_0-1667401117999.png

HamidBee_1-1667401140605.png

HamidBee_2-1667401172879.png

 

No I need to use the EnableFolding=true command and this is only available when using the Value.NativeQuery function. I created a new step and typed the following:

 

 

= Value.NativeQuery( Source, "
SELECT OID.OrderID,O.OrderDate,UnitPrice*Quantity AS Total 
FROM Orders As O
FULL OUTER JOIN [Order Details] AS OID
ON O.OrderID = OID.OrderID", null, [EnableFolding=true])

 

HamidBee_3-1667401238125.png

 

Now if I apply any parameter based filters to the dataset it will work without any errors.

 

View solution in original post

2 REPLIES 2
HamidBee
Impactful Individual
Impactful Individual

I was able to fix the following by firstly using Import mode instead of DirectQuery. Here are the full steps I followed:

HamidBee_0-1667401117999.png

HamidBee_1-1667401140605.png

HamidBee_2-1667401172879.png

 

No I need to use the EnableFolding=true command and this is only available when using the Value.NativeQuery function. I created a new step and typed the following:

 

 

= Value.NativeQuery( Source, "
SELECT OID.OrderID,O.OrderDate,UnitPrice*Quantity AS Total 
FROM Orders As O
FULL OUTER JOIN [Order Details] AS OID
ON O.OrderID = OID.OrderID", null, [EnableFolding=true])

 

HamidBee_3-1667401238125.png

 

Now if I apply any parameter based filters to the dataset it will work without any errors.

 

artemus
Employee
Employee

I think you forgot the EnableFolding=true in the Sql.Database 3rd parameter. This is needed if you want folding to work with SQL when using a custom query.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors