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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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




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

Community Support
Community Support


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,

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.



Helpful resources


Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors