The attendee said, “I have a data set showing the prior and current status for support tickets. I want to report the text from the Status field in the Values area of a pivot table.” While the Data Model, introduced in Excel 2013, and CONCATENATEX provide a solution, these calculations are only available in Windows versions of Excel. They won’t work in Excel for Android, Excel for iOS, or Excel for Mac.

DAX stands for Data Analysis eXpressions. The DAX formula language is a new set of functions for creating calculated fields in a pivot table. While many of the functions are similar to the functions in regular Excel, there are several powerful additions that allow calculations previously impossible in a pivot table.

In order to use DAX in a pivot table, follow these steps:

1. Select one cell in your data set and press Ctrl+T (or go to Home, Format as Table).

2. By default, the new table will be called Table1. Click on the Table Tools Design tab in the Ribbon and assign the table a name. The table name can’t have spaces. A name such as “TicketData” would work.

3. Select one cell in the table. From the Insert Tab, choose Pivot Table.

4. In the Create Pivot Table dialog, choose the box for “Add this data to the Data Model.”

5. A new worksheet will appear with the Pivot Table Fields list. Start to build your pivot table by dragging fields to the Rows and Columns area. When your pivot table is based on the Data Model, there will be a few subtle differences in the Pivot Table Fields list. First, the words “Active and All” allow you to add more data sets to the pivot table. Second, the name of the table appears at the top of the fields from that table.

6. Right-click the name of the table and choose Add Measure.

Note: The word “Measure” is a database professional’s word for Calculated Field. When the Power Pivot add-in debuted in Excel 2010, the calculated fields were called Measures. Microsoft tried to soften the word in Excel 2013, and the menu choice in Figure 1 appeared as Insert Calculated Field. This was designed to be more familiar for people using Excel. But Excel pivot tables already offer a different feature called Calculated Fields. To avoid confusion, the term changed to “Measure” in Excel 2016. I would have preferred a completely new term, such as “Super Amazing Calculated Field.”

7. In the Measure dialog, type a measure name such as “StatusResults.”

8. Enter the formula =CONCATENATEX(TicketData,[Status],", ").

9. Click the Check DAX Formula button to make sure the syntax is correct.

10. You can specify the number format for Measures, which I think is great. For a text result, however, the only valid choice is General, so leave the number format as General.

Note: The syntax for CONCATENATEX is (Table Name, Expression, Delimiter). In the formula in Step 8, TicketData corresponds to the name that you used in Step 2, and [Status] is the name of the field in the source data. To use the AutoComplete feature in the Create Measure dialog, type a left square bracket. The AutoComplete list will show a list of fields from your data set. Click on one name, and press Tab.

11. Click OK to create the new calculated field. The calculation won’t show up in the pivot table automatically. Instead, a new field will appear in the Pivot Table Fields list. Drag the new field to the Values area.

The Subtotal and Grand Total results for a text field might be unexpected. The Grand Total Column of Apple and Quince will be “Apple, Quince.” The Subtotal for the Central region will be “Orange, Apple, Apple, Vanilla, Elderberry, Mango, Watermelon.” As you can imagine, the bottom-right cell containing the grand total will contain one word for every row in the original data. These results cause the pivot table columns to be unreasonably wide.

In many cases, the pivot table will look better if you remove the grand totals and subtotals:

12. Select Design, Grand Totals, Off For Rows and Columns.

13. Right-click on the first Subtotal label in Column A and unselect Subtotal Region.

The result is a pivot table with text in the Values area.

Just like any other pivot table, you can rearrange the fields in the Rows and Columns area and the results will recalculate.

Download this month’s workbook to try it out for yourself: SF-2018-07-TextValues.

Update from Bill Jelen: After using this method for a few weeks, I and others noticed that in some data sets, the concatenated values would contain duplicates. You can remove the duplicates by changing =CONCATENATEX(TicketData,[Status],", ") to =CONCATENATEX(Values(TicketData[Status]),TicketData[Status],", "). (Thanks to Rob Collie at PowerPivotPro.com for suggesting the updated formula.)

The VALUES function returns a new table with the unique values found in a column.


SF SAYS

The DAX formula language offers many new calculations for your pivot tables.


Update from Bill Jelen on January 3, 2019:

Comments by VB, Alex, Izabela, and JL are all pointing to the pivot table not reacting when you try to add the calculated field to the pivot table.

I've researched the problem and isolated the issue. I've reported the bug to Microsoft. There is a limitation in Excel that the result of a formula can’t exceed 32,767 characters. If your new Measure creates a cell that’s more than 32,767 characters, the pivot table simply refuses to react. There’s nothing Microsoft can do to increase the number of character limit, but I believe they should provide an error message that alerts you the pivot table can’t be recalculated due to the limitation.

There will be some data sets where the problem is the Grand Total row. If the length of all the unique values in the data set is more than 32,767 characters but the length for each customer is less than 32,767 characters, then removing the Grand Totals before adding the Measure to the Values Area will allow the pivot table to work.

In a similar fashion, if you have multiple fields in the Rows area, removing Subtotals for the outer row fields might allow the pivot table to work. Select Format, Subtotals, Do Not Show Subtotals.

The problem with all of these workarounds is that there’s no warning that the pivot table is unresponsive. That can result in a situation where you click Refresh, the pivot table won’t refresh, and, without the warning, you won’t know that it hasn’t.