PIVOT Transformation Issue in SSIS

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmailFacebooktwittergoogle_plusredditpinterestlinkedintumblrmail
FacebooktwitterlinkedinrssyoutubeFacebooktwitterlinkedinrssyoutube

Today I’ve found a bug in SSIS Pivot Transform component reported as a question in TechNet forums here.

Reported issue was related to pivoting some records based, result of PIVOT transformation in SSIS was not as expected to be. read below for detailed explanation;

Scenario Explanation:

This is a sample of incoming data set:

The expected output after pivot with Month as Set Key, and Test as Pivot Key is :

But the problem is using PIVOT transformation generates the output below:

Cause:

This issue occurred because SSIS Pivot Transformation consider the
ORDER or records base on the SET Key, in this example Set key is Month, and data rows are not sorted by month, so result of using Pivot transformation will be as below (which is wrong result set):

Resolution (Work around):

sorting incoming data set based on the Set key before the Pivot transformation is the work around for this issue. sorting can be done with Order by clause in the source query, when you are fetching data from databases. But in this example we fetch data from excel, so we use SORT Transformation. and sorting based on Set key in this example means sorting based on Month, after sorting we redirect result to Pivot transformation. here you can see result (as expected and correct):

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmailFacebooktwittergoogle_plusredditpinterestlinkedintumblrmail
FacebooktwitterlinkedinrssyoutubeFacebooktwitterlinkedinrssyoutube
Reza Rad on FacebookReza Rad on LinkedinReza Rad on TwitterReza Rad on Youtube
Reza Rad
Trainer, Consultant, Mentor
Reza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He has a BSc in Computer engineering; he has more than 20 years’ experience in data analysis, BI, databases, programming, and development mostly on Microsoft technologies. He is a Microsoft Data Platform MVP for nine continuous years (from 2011 till now) for his dedication in Microsoft BI. Reza is an active blogger and co-founder of RADACAD. Reza is also co-founder and co-organizer of Difinity conference in New Zealand.
His articles on different aspects of technologies, especially on MS BI, can be found on his blog: https://radacad.com/blog.
He wrote some books on MS SQL BI and also is writing some others, He was also an active member on online technical forums such as MSDN and Experts-Exchange, and was a moderator of MSDN SQL Server forums, and is an MCP, MCSE, and MCITP of BI. He is the leader of the New Zealand Business Intelligence users group. He is also the author of very popular book Power BI from Rookie to Rock Star, which is free with more than 1700 pages of content and the Power BI Pro Architecture published by Apress.
He is an International Speaker in Microsoft Ignite, Microsoft Business Applications Summit, Data Insight Summit, PASS Summit, SQL Saturday and SQL user groups. And He is a Microsoft Certified Trainer.
Reza’s passion is to help you find the best data solution, he is Data enthusiast.

Leave a Reply

Your email address will not be published. Required fields are marked *