[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-30 (世界標準時間)。"],[],[],null,["# Aggregating across rows (row totals) in table calculations\n\n\u003e You can use [shortcut calculations](/looker/docs/table-calculations#quick_calculations) to perform common calculations on numeric fields that are in an Explore's data table without using Looker [functions and operators](/looker/docs/functions-and-operators) when you have the [permissions](/looker/docs/admin-panel-users-roles#create_table_calculations) to create table calculations.\n\n\nThere may be situations where you or other users want to analyze [pivoted data in Explores](/looker/docs/creating-and-editing-explores#pivoting_dimensions). This page discusses how you can use the [`pivot_row()` table calculation function](/looker/docs/functions-and-operators#pivot-related_functions_for_table_calculations_only) to create row totals and other aggregations that can help users gain further insight into Explore data.\n\nHow does `pivot_row()` work?\n----------------------------\n\n\nThe `pivot_row()` table calculation function groups all the values of a pivoted row into a list.\n\n\nThis example uses the following Explore data table with **Products Count** grouped by **Orders Created Date** and pivoted by **Users Age** :\n\n\nYou can use `pivot_row()` to write a table calculation that will group all of the **Products Count** row values into one column: \n\n```\npivot_row(${products.count})\n```\n\n\nThe table calculation then outputs a new column that displays a list of all the values of **Products Count** in each pivoted row:\n\nCalculating the row total using `pivot_row()`\n---------------------------------------------\n\n\nYou can also perform calculations on the lists that you create with the `pivot_row()` function to make further analyses. For example, you can calculate row totals by using the `sum()` function on the listed values that are returned by `pivot_row()`.\n\n\nUsing the same Explore data table with **Products Count** grouped by **Orders Created Date** and pivoted by **Users Age** , you can write the following table calculation to output the row totals for **Products Count**: \n\n```\nsum(pivot_row(${products.count}))\n```\n\n\u003cbr /\u003e\n\n\nThe table calculation sums the list of **Products Count** values that are calculated with the `pivot_row()` function and outputs a new column that displays the total of each pivoted row:\n\nCalculating other aggregations using `pivot_row()`\n--------------------------------------------------\n\n\nYou can use the `pivot_row()` function to aggregate across any pivoted row. For example, rather than a `sum()`, you can also calculate the `mean()` of the values in the list, the `max()`, the `min()`, and so on. This section of the [Looker functions and operators](/looker/docs/functions-and-operators#functions_for_table_calculations_only) documentation page lists all the available table calculation functions and operators.\nYou can also perform more complex calculations across pivot rows with the `pivot_row()` function, including a percent of total. Read about how to use `pivot_row()` to calculate a percent of total across rows in the [How to calculate percent-of-total](/looker/docs/best-practices/how-to-calculate-percent-of-total) Best Practices page.\n\n\u003cbr /\u003e"]]