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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Anonymous
Not applicable

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
Super User
Super User

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




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn
Let's connect on LinkedIn


Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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