Ad Code

Data Science labs blog

How to create a Sum Column in Power BI dax ?

 How to create a Sum Column in Power BI dax ?


Method 1: Using DAX (Data Analysis Expressions)

  1. 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 and ColumnName with the name of your column.
  2. 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.

Method 2: Using the Power Query Editor

  1. Open Power Query Editor:

    • Go to the Home tab.
    • Click on Transform data to open the Power Query Editor.
  2. 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 and ColumnName with the name of your column.
    • Click OK.

Method 3: Using a Visual

  1. 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

  1. Example Using DAX Measure:

    DAX
    Total Sales = SUM(Sales[Amount])
  2. Example Using Power Query Editor:

    • Suppose you have a table named Sales and a column named Amount.
    • In Power Query Editor, you would use:
      M
      List.Sum(Sales[Amount])

Visual Representation

  • Create a card visual to display the total sum.
  • Drag your measure (e.g., Total Sales) to the Values field well of the card visual.

These methods will help you sum a column in Power BI effectively.

Reactions

Post a Comment

0 Comments