How to create a Sum Column in Power BI dax ?
Method 1: Using DAX (Data Analysis Expressions)
Create a New Measure:
- Go to the
Modeling
tab. - Click on
New Measure
. - In the formula bar, type the following formula:DAX
Total Sum = SUM(TableName[ColumnName])
- Replace
TableName
with the name of your table andColumnName
with the name of your column.
- Go to the
Create a New Column:
- Go to the
Modeling
tab. - 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
Home
tab. - Click on
Transform data
to open the Power Query Editor.
- Go to the
Add a Sum Column:
- In the Power Query Editor, select the table.
- Go to the
Add Column
tab. - Click on
Add Custom Column
. - In the custom column formula, type:M
List.Sum(TableName[ColumnName])
- Replace
TableName
with the name of your table andColumnName
with 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
Values
field 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
Sales
and 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 theValues
field well of the card visual.
These methods will help you sum a column in Power BI effectively.
0 Comments