Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Pivot/Unpivot in dataflow task SSIS

$
0
0

I have the data in following format:

MONTH	Number of Installs	STATION	          Month Name
Jul	0	                ALPENA	                Jul
Jul YTD	0                       ALPENA	                Jul
Jul	0	                BIG RAPIDS	        Jul
Jul YTD	0	                BIG RAPIDS	        Jul
Jul	0	                CADILLAC	        Jul
Jul YTD	14	                CADILLAC	        Jul


I need to convert it to following format:

YTD   MTD        STATION
0     0         ALPENA
0     0         BIG RAPIDS
14    0         CADILLAC

MTD column should show values of rows with abbreviated month name

YTD column should show values of rows with abbreviated month name and YTD

I can use pivot transformation, but it requires pivotKey values to be specified as Jul and Jul YTD. I need to avoid this because the MONTH column changes its values based on current month. Since this is july month, it has Jul and Jul YTD values. If it is August, it will have Aug and Aug YTD values. So pivot should happen dynamically rather specifying Jul and Jul YTD as pivotKey values.

Any ideas on how to do this? Thanks in advance




EDIT: Sorry for the table format.. I tried many times, it is not showing appropriately

Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>