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
JohnColtrane
New Member

SQL Query Error

I have created the following query SQL 2014 and successfully executed it:

 

select
CONVERT(CHAR(7),DATEADD(MONTH,DATEDIFF(MONTH,0,StartDate),0),120) as 'Month & Year',
Shift,
SUM(DownTime) as 'Month Total Down Time',
SUM(DownTime)+
COALESCE(
(
select SUM(s2.DownTime)
FROM LineData s2
where
s2.Shift = s.Shift
and s2.StartDate >= DATEADD(YEAR,DATEDIFF(YEAR,0,s.StartDate),0) --Verify the date is in the same year
and s2.StartDate < DATEADD(YEAR,1,DATEADD(YEAR,DATEDIFF(YEAR,0,s.StartDate),0))
and DATEADD(MONTH,DATEDIFF(MONTH,0,s.StartDate),0) > s2.StartDate --Verify the date s less than s.TDate
),0) as 'YTD Total Down Time'
from LineData s
group by
DATEADD(MONTH,DATEDIFF(MONTH,0,s.StartDate),0),
DATEADD(YEAR,1,DATEADD(YEAR,DATEDIFF(YEAR,0,s.StartDate),0)),
DATEADD(YEAR,DATEDIFF(YEAR,0,s.StartDate),0),
Shift
ORDER BY
'Month & Year',
Shift

 

When I attempt to use the query in a direct query import I receive the following error:

PowerBI error: Microsoft SQL: The Order by clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless top or for xml is also specified in PowerBI

 

However, if I open Power Query Editor I see my query with the correct data that the query produces. Unfortunately, if I attempt to apply the query I receive this error:

 

Failed to save modifications to the server. Error returned: 'Partitions that contain a full dataset (not sampled data) have to be configured for DirectQuery and Full DataViews, or use Import query mode to retrieve data. This model appears to have partitions that are non-compliant. Please check partition configuration.'

 

Can someone please explain why Power BI can not run a query that SQL can? And how can I resolve the issue?

 

Thanks in advance.

 

Mark

1 ACCEPTED SOLUTION
JohnColtrane
New Member

I added a "Top" to the query and Power BI accepted it. Had to play around with the query in query editor before I got it to appear on the Desktop. Everything is working now, I guess I just need more experience with Power BI.

View solution in original post

1 REPLY 1
JohnColtrane
New Member

I added a "Top" to the query and Power BI accepted it. Had to play around with the query in query editor before I got it to appear on the Desktop. Everything is working now, I guess I just need more experience with Power BI.

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.