locked
Unpivot

    General discussion

  • Here's a short post on how I managed to unpivot some data I had.

    Many queries made to business data return months in columns.  This is not ideal as it's easier to process the data with months being represented by 1 column.  Here's the Unpivot function I use to month months into a column.

    pivTable = Table.Unpivot(Table.NewTable, {"Oct-2012", "Nov-2012", "Dec-2012"},"Date", "Value")

    An interesting point would be if months are dynamic i.e. the query runs a range of data : Oct-12 : Dec-12. It would be good if there was a way to collect columns of a particular type i.e. Date and have these passed columns into the UnPivot function without having to specify each one.  

    Regards.

    Lee Hawthorn
    ------------------------------------------------------------------
    Check out my Performance Management blog at leehbi.com
    ------------------------------------------------------------------

    Monday, July 01, 2013 2:10 PM

All replies