Code covered by the BSD License  

Highlights from
Pivot/unPivot

4.33333

4.3 | 3 ratings Rate this file 18 Downloads (last 30 days) File Size: 73.71 KB File ID: #26119
image thumbnail

Pivot/unPivot

by Oleg Komarov

 

16 Dec 2009 (Updated 05 Feb 2010)

Group a flat dataset into pivot table and unpivot it back

| Watch this File

File Information
Description

These two functions are meant to format a flat dataset into a pivot table and to unpivot it back.
They imitate the T_SQL pivot/unpivot commands or the pivoting functionalities of the spreadsheet softwares.

If you a have a large set of values which are described by two features (or more) this function allows you to group those values by those two features.

For example, you can sum to the total amount sold over the last 10 months by any of your employees or you can count the number of contracts signed by region and by salesmen and so on...

For detailed help and description see the published M-file or the help of the functions.

For examples see the attached snapshot.
   
Comments/suggestions/error reports are welcome.

Thanks to Jos (10584) for cell2float.

p4v3

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
CELL2FLOAT

MATLAB release MATLAB 7.9 (2009b)
Other requirements Tested on R14SP3 (7.1) and on R2009b. In-between compatibility is assumed. Cell2float is implemented as a really compact subfunction.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
17 Dec 2009 Oleg Komarov

Previous releases compatibility is not achieved at the moment. I'll update the submission asap.

19 Mar 2010 Santosh  
06 Feb 2011 Vandhana Gopalakrishnan  
31 May 2011 Christian Weber  
Please login to add a comment or rating.
Updates
20 Dec 2009

Corrected syntax for compatibility; edited description; added link to the submission

05 Feb 2010

unPivot: fixed column position in Out (the first was switched with the second)

Tag Activity for this File
Tag Applied By Date/Time
pivot Oleg Komarov 16 Dec 2009 14:07:03
unpivot Oleg Komarov 16 Dec 2009 14:07:03
stack Oleg Komarov 16 Dec 2009 14:07:03
unstack Oleg Komarov 16 Dec 2009 14:07:03
group Oleg Komarov 16 Dec 2009 14:07:03
reshape Oleg Komarov 16 Dec 2009 14:07:03
group ZMI 07 Jan 2010 12:32:24
group Mai 15 Nov 2011 15:48:18

Contact us at files@mathworks.com