Aliasing Columns inside SUMMARIZE

SimonNU

Board Regular
Joined
Jul 11, 2013
Messages
140
A simple request: I'm trying to name the columns in the SUMMARIZE function but I can't figure out how. For example, I'd simply like to rename "Payroll[Employee Name]" to something a little more user friendly. Any suggestions? It's rather easy to do with ADDCOLUMNS...

Code:
EVALUATE
ADDCOLUMNS (
    SUMMARIZE (
        FILTER ( Payroll, Payroll[Employee Code] = "12345" ),
        Payroll[Employee Name],
        Payroll[Employee Code],
        'Level Table'[Employee Level Name],
        Payroll[Employee DOB],
        'Date Table'[Transaction Date],
        'Date Table'[Period]
    ),
    "Hours", [Measure Hours],
    "Hourly Wage", [Measure Hourly Wage],
    "Total Income", [Measure Total Income]
)
ORDER BY Payroll[Transaction Date]


Thanks,
Simon
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hello,
Yes, ADDCOLUMNS is the way to go:

Code:
EVALUATE
ADDCOLUMNS (
    SUMMARIZE (
        FILTER ( Payroll, Payroll[Employee Code] = "12345" ),
        Payroll[Employee Name],
        Payroll[Employee Code],
        'Level Table'[Employee Level Name],
        Payroll[Employee DOB],
        'Date Table'[Transaction Date],
        'Date Table'[Period]
    ),
    [COLOR=#ff0000]"Name", Payroll[Employee Name],[/COLOR]
    "Hours", [Measure Hours],
    "Hourly Wage", [Measure Hourly Wage],
    "Total Income", [Measure Total Income]
)
ORDER BY Payroll[Transaction Date]

Or if you want a table with just the Aliases:

Code:
[FONT=arial]EVALUATE
SUMMARIZE(
    ADDCOLUMNS(
        FILTER ( Payroll, Payroll[Employee Code] = "12345" ),
[SIZE=2][FONT=Verdana]          "Name", Payroll[Employee Name],[/FONT][/SIZE]
[SIZE=2]             "Hours", [Measure Hours],[/SIZE]
[SIZE=2]             "Hourly Wage", [Measure Hourly Wage],[/SIZE]
[SIZE=2]             "Total Income", [Measure Total Income[/SIZE]
    ),
    [Name],
    [Hours],
    [Hourly Wage],
    [Total Income]
)
[/FONT]

/Daniel
 
Upvote 0
Thanks Daniel!

Your first method will duplicate the columns: once for the SUMMARIZE and then again for ADDCOLUMNS.

I think the second one will work but I avoided it due to slow query execution. I'll do some testing on it today.


Simon
 
Upvote 0
Unfortunately method 2 is very slow.

Original approach: 122 milliseconds
Method 2: 12 seconds
 
Upvote 0
Oh really? Strange...wonder why that is.
Perhaps it has got something to do with having ADDCOLUMNS in the first step after FILTER, that it produces such a big table.
Maybe something like this instead?


Code:
EVALUATE
SUMMARIZE(
    ADDCOLUMNS (
         SUMMARIZE (
             FILTER ( Payroll, Payroll[Employee Code] = "12345" ),
             Payroll[Employee Name],
             Payroll[Employee Code],
             'Level Table'[Employee Level Name],
             Payroll[Employee DOB],
             'Date Table'[Transaction Date],
             'Date Table'[Period]
         ),
         "Name", Payroll[Employee Name],
         "Hours", [Measure Hours],
         "Hourly Wage", [Measure Hourly Wage],
         "Total Income", [Measure Total Income]
    ),
[Name],
[Hours],
[Hourly Wage],
[Total Income]
)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,090
Messages
6,176,292
Members
452,719
Latest member
Boonchai Charoenek

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top