Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

RE-Defining Column cells in Pivot Table

Posted on 2015-02-11
7
Medium Priority
?
72 Views
Last Modified: 2015-02-12
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
Comment
Question by:Rickzzz
  • 3
  • 3
7 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40603613
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
 
LVL 34

Expert Comment

by:Rob Henson
ID: 40603622
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
 

Author Comment

by:Rickzzz
ID: 40603693
@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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40603697
No query attached.
0
 

Author Comment

by:Rickzzz
ID: 40603709
It is now and SQL 2012. Thanks.
0
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 2000 total points
ID: 40605164
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
 

Author Closing Comment

by:Rickzzz
ID: 40605938
Outstanding, thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question