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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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

v-cgao-msft
Community Support
Community Support

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors