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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
FBiazotto
New Member

Query error when applied to Power BI, but works on Powe Query.

Greetings. I'm new to Power BI and I'm starting with a simple query that works in PowerQuery returning the result, but when I apply to Power BI I get the following error: "Incorrect syntax near the keyword 'set'.Incorrect syntax near') '."

 

Query:

set dateformat dmy
select b.nome Setor , COUNT (a.setor) TOTAL, a.COMPETENCIA from movimento a
inner join setor b on (a.setor = b.setor)
where DATAHORA between '01/07/2020' and '31/07/2020 23:59:59'
and TIPOMOV = 'S'
and Localiza = '1'
group by b.nome , a.setor , a.COMPETENCIA
order by COUNT (a.setor) desc

 

Error: Incorrect syntax near the keyword 'set'.Incorrect syntax near') '.

2 ACCEPTED SOLUTIONS
edhans
Super User
Super User

I would avoid keying in SQL statements directly into the advanced editor. It breaks further folding. If you want to key in SQL, create a view. Otherwise, use the Power Query UI to generate your steps. In many cases, it will fold a query back to the SQL server for you.

 

Additionally, there are security issues with advanced SQL statements in the service requiring higher privileges to run them.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

Great. Post back with specifics if you need help.

 

When you are building your steps in Power Query, on the right side where APPLIED STEPS are, right-click on a step and if you see "View Native Query" you will know that a SQL statement is being generated and sent back to the server so it can do the work for you. 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

3 REPLIES 3
edhans
Super User
Super User

I would avoid keying in SQL statements directly into the advanced editor. It breaks further folding. If you want to key in SQL, create a view. Otherwise, use the Power Query UI to generate your steps. In many cases, it will fold a query back to the SQL server for you.

 

Additionally, there are security issues with advanced SQL statements in the service requiring higher privileges to run them.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

I'll try, thanks!

Great. Post back with specifics if you need help.

 

When you are building your steps in Power Query, on the right side where APPLIED STEPS are, right-click on a step and if you see "View Native Query" you will know that a SQL statement is being generated and sent back to the server so it can do the work for you. 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors