Reputation: 11
I have a simple table in Excel like the following one:
I need to transform it so that it looks like this:
How can I accomplish this in Excel using pivot table or power pivot (macros excluded)?
Thanks!
Update: In my specific case, the pivot does not need to show grand totals. However there may be other situations where they are.
Upvotes: 0
Views: 2638
Reputation: 11
Here is the best solution I found so far starting from the suggestions I received:
Make sure to check the "Add this data to the Data Model" in order to be able to create a new Measure.
Create the new Measure and use the following function:
=CONCATENATEX(Table1;Table1[Result] & " with " & Table1[Grade];", ")
Remarks: The function CONCATENATEX offers the advantage over the funtion VALUES that the pivot table can have grand totals on rows and columns, which by default are enabled when you create a brand new pivot.
Upvotes: 1
Reputation: 40244
Create a pivot table with Student
on row and Exam
on columns and add a measure that concatenates Result
and Grade
.
TextMeasure = VALUES(TableName[Result]) & " with " & VALUES(TableName[Grade])
Note that this will break for subtotals and grand totals. However, there are ways to fix that.
One way is to do a single value check (and return blank otherwise):
TextMeasure =
IF (
HASONEVALUE(TableName[Result]) && HASONEVALUE (TableName[Grade]),
VALUES(TableName[Result]) & " with " & VALUES(TableName[Grade])
)
A shorter way is to just use MAX
instead of VALUES
but this won't have blanks for totals:
TextMeasure = MAX(TableName[Result]) & " with " & MAX(TableName[Grade])
Upvotes: 0