• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 77
  • Last Modified:

RE-Defining Column cells in Pivot Table

I need to alter the structure of the top PivotTable as created by Excel in the image below to how I've manually copied it to the bottom PivotTable. Changing "evaluationMonth" as defined as a DATE to "Month1", "Month2", etc..

Btw, the data originates from a SQL query, in case it may be easier for me to do something to the data before copying to Excel.

Thanks in advance for any assistance.

Alter-PivotTable-Column.PNG
0
Rickzzz
Asked:
Rickzzz
  • 3
  • 3
1 Solution
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
I would change the query before Pivoting.

However, can you show the results of your SQL Query, and let me know what version of SQL you have.
0
 
Rob HensonFinance AnalystCommented:
I assume your dates are mmddyyyy format ie 04/01/2007 is 1st April.

To convert the dates to Month1, Month2 etc one way would be to do this in the source data with a formula and then pulling that new column into the pivot as column headers rather than the date.

However, the dollar amounts in the table have physically moved; $72,028 in original is at intersection of column 06/01/2007 and row 06/01/2007 but column Month1 and row 06/01/2007 in required format.

How are you determining the movement. Could this also be done as formula in the source data?

Thanks
Rob H
0
 
RickzzzAuthor Commented:
@Phillip
In the attached query, effMonth, evalMonth , coverage and inforceAmount are ultimately copied to Excel. "effMonth" is derived from an actual effective date of a policy. Ultimately, I group these policies by their respective effective month and follow their development, by month (evalMonth), to a point in time.

@Rob
The idea is to have the evaluated months of these groups of policies start in the 1st cell as "Month1", rather than the actual date of the month, which is unimportant. So, for instance, the 6/1/2007 group would not have activity until 6/1/2007 and forward. This activity should start in the 1st cell, thus the move of the $72 to the 1st cell. Again, as "Month 1" and so on is better descriptive than the actual month (June 2007).

Hope that makes sense and thanks!
ICS-to-EE-for-Eval.sql
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
No query attached.
0
 
RickzzzAuthor Commented:
It is now and SQL 2012. Thanks.
0
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
In

SELECT
      effMonth,
      evalMonth,
      coverage,
      SUM(inforcePremium) inforcePremium

Change (or add after)

      evalMonth,

to

         'Month' + convert(nvarchar(10),dense_rank() over(partition by effMonth order by evalMonth)) as evaluationMonth,
0
 
RickzzzAuthor Commented:
Outstanding, thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now