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
NMOORE
Helper II
Helper II

Error Code Incorrect Syntax When Pivoting from SQL

Hi all,

 

I have the following error when I go to unpivot columns in power query. Everything works fine regarding access to the account and making other changes, it is only when I go to unpivot the columns that I get a problem - my current theory is because I'm trying to pivot 300+ columns. But rather than try a work around I just wanted to confirm before creating extra work (as I have to do this on a few tables). Thanks for any info. Cheers

 

NMOORE_0-1713189318644.png

 

4 REPLIES 4
v-belled
Regular Visitor

I have the same error as soon as I select 5 or more columns and then try to unpivot others cloumns...

With me it was too many columns I was trying to pivot, I cannot confirm 100% but it was the only thing that made sense. I seperated them, unpivoted then appended, all has worked fine since

Anonymous
Not applicable

Hi @NMOORE ,

Based on the error message you've provided, it seems like the issue is related to the SQL syntax, specifically near the 'from' keyword and '$Pivot'. Try using some tools to check the queries sent to the data source for errors near those keywords.
SQL Server Profiler - SQL Server Profiler | Microsoft Learn

As you've suspected, pivoting a large number of columns (300+ in your case) can sometimes lead to issues. If possible, try to reduce the number of columns you're attempting to unpivot in a single operation to see if you can figure out the error.

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Hi Gao,

 

Thanks for your reply.

 

I assumed as much regarding the SQL and can look into that. The only thing is the SQL table is fine in Power query  until I go to pivot, and I don't think the word 'Pivot' is used building the table. I guess this would make the culprit the excessive columns I'm trying to Pivot, but I can't find anything regarding limitations and was hoping to understand this in its entirety before I carry on.

 

Cheers

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.