How to create a Sum Column in Power BI dax ?
Method 1: Using DAX (Data Analysis Expressions)
Create a New Measure:
- Go to the
Modelingtab. - Click on
New Measure. - In the formula bar, type the following formula:DAX
Total Sum = SUM(TableName[ColumnName]) - Replace
TableNamewith the name of your table andColumnNamewith the name of your column.
- Go to the
Create a New Column:
- Go to the
Modelingtab. - Click on
New Column. - In the formula bar, type the following formula:DAX
Total Sum = SUM(TableName[ColumnName]) - This creates a calculated column that sums the values in the specified column.
- Go to the
Method 2: Using the Power Query Editor
Open Power Query Editor:
- Go to the
Hometab. - Click on
Transform datato open the Power Query Editor.
- Go to the
Add a Sum Column:
- In the Power Query Editor, select the table.
- Go to the
Add Columntab. - Click on
Add Custom Column. - In the custom column formula, type:M
List.Sum(TableName[ColumnName]) - Replace
TableNamewith the name of your table andColumnNamewith the name of your column. - Click
OK.
Method 3: Using a Visual
- Create a Visual:
- Drag and drop a table or matrix visual to the canvas.
- Drag the column you want to sum to the
Valuesfield well. - Power BI will automatically sum the values in the column.
Examples
Example Using DAX Measure:
DAXTotal Sales = SUM(Sales[Amount])Example Using Power Query Editor:
- Suppose you have a table named
Salesand a column namedAmount. - In Power Query Editor, you would use:M
List.Sum(Sales[Amount])
- Suppose you have a table named
Visual Representation
- Create a card visual to display the total sum.
- Drag your measure (e.g.,
Total Sales) to theValuesfield well of the card visual.
These methods will help you sum a column in Power BI effectively.
0 Comments