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
andypettit12
Frequent Visitor

Data loads in Power Query but not Power BI

Hello!

 

Don't really have SQL experience so I don't know where to begin to find the issue here. Data shows up fine in Power Query, no issues in preview:

andypettit12_0-1710992410050.png

 

Also no issues loading into Excel. But when I try to load into Power BI, I get this message:

andypettit12_1-1710992643401.png

 

Here is the query I'm exporting from Wonderware Query:

 

SET NOCOUNT ON
DECLARE @StartDate DateTime
DECLARE @EndDate DateTime
SET @StartDate = '20231219 23:26:30.309'
SET @EndDate = '20240320 23:26:30.309'
SET NOCOUNT OFF
SELECT * FROM (
SELECT History.TagName, DateTime, Value, vValue, SourceTag, StartDateTime
FROM History
WHERE History.TagName IN ('P6_M1_Batch_Active_ID')
AND wwRetrievalMode = 'Delta'
AND wwTimeDeadband = 500
AND wwQualityRule = 'Extended'
AND wwVersion = 'Latest'
AND DateTime >= @StartDate
AND DateTime <= @EndDate) temp WHERE temp.StartDateTime >= @StartDate

 

 

I'm just pasting this into the SQL Statement area when getting data from the SQL server. This is what Power Query is showing in the advanced editor:

 

let
    Source = Sql.Database("PLT111", "Runtime", [Query="SET NOCOUNT ON#(lf)DECLARE @StartDate DateTime#(lf)DECLARE @EndDate DateTime#(lf)SET @StartDate = '20231219 23:26:30.309'#(lf)SET @EndDate = '20240320 23:26:30.309'#(lf)SET NOCOUNT OFF#(lf)SELECT  * FROM (#(lf)SELECT History.TagName, DateTime, Value, vValue, SourceTag, StartDateTime#(lf) FROM History#(lf) WHERE History.TagName IN ('P6_M1_Batch_Active_ID')#(lf) AND wwRetrievalMode = 'Delta'#(lf) AND wwTimeDeadband = 500#(lf) AND wwQualityRule = 'Extended'#(lf) AND wwVersion = 'Latest'#(lf) AND DateTime >= @StartDate#(lf) AND DateTime <= @EndDate) temp WHERE temp.StartDateTime >= @StartDate", HierarchicalNavigation=true])
in
    Source

 

 

What am I missing here? Any help would be greatly appreciated. Thank you!

2 REPLIES 2
v-jingzhan-msft
Community Support
Community Support

Hi @andypettit12 

 

You may try this 

 

DECLARE @StartDate DateTime
DECLARE @EndDate DateTime
SET @StartDate = '20231219 23:26:30.309'
SET @EndDate = '20240320 23:26:30.309'
SELECT * FROM (
SELECT History.TagName, DateTime, Value, vValue, SourceTag, StartDateTime
FROM History
WHERE History.TagName IN ('P6_M1_Batch_Active_ID')
AND wwRetrievalMode = 'Delta'
AND wwTimeDeadband = 500
AND wwQualityRule = 'Extended'
AND wwVersion = 'Latest'
AND DateTime >= @StartDate
AND DateTime <= @EndDate) temp WHERE temp.StartDateTime >= @StartDate

 

Based on my test, DECLARE and SET are supported. Probably "SET NOCOUNT ON" and "SET NOCOUNT OFF" is not supported. 

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

Joe_Barry
Responsive Resident
Responsive Resident

Hi @andypettit12 

 

Maybe Power BI doesn't support that syntax. I would suggest removing the SET statements and using only Select instead.

 

Thnaks

Joe

 

If you found my answer helpful and it solved your issue, please accept as solution

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
Top Kudoed Authors