Forum Discussion

GustavoV1's avatar
GustavoV1
Frequent Visitor
6 years ago
Solved

How can I create this columns

Hi 

I have a table which have a column for an item and any columns (cost by year) as years I have

 

How can I resume this table to one which has one column for item a four columns after, one for all estimated costs, other for costs before 2020, one for costs in 2020 and other for cost after 2020.

 

Thanks

  • You should be able to do these steps in the query editor to get that result.

     

    1. Click on the Items column and right click and choose unpivot other columns

    2.Add a custom column with nested if... then... else to add your <2020, 2020, and >2020 based on the year value in the Attribute column

    3. Pivot that new column, choosing a sum aggregation on the Value column

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat

1 Reply

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    You should be able to do these steps in the query editor to get that result.

     

    1. Click on the Items column and right click and choose unpivot other columns

    2.Add a custom column with nested if... then... else to add your <2020, 2020, and >2020 based on the year value in the Attribute column

    3. Pivot that new column, choosing a sum aggregation on the Value column

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat