How can I use SUM IF in Power BI to calculate data?

SUM IF is a useful function in Power BI that allows users to sum up specific data based on certain criteria. This function can be used to calculate and analyze data in a more efficient and organized manner. By setting conditions or criteria, such as a specific date range or category, the function will only sum up the data that meets those requirements. This allows for targeted analysis and accurate calculations. By utilizing the SUM IF function in Power BI, users can easily and effectively calculate data and gain valuable insights for decision making.

Use SUM IF in Power BI (With Example)


You can use the following syntax in DAX to write an SUM IF function in Power BI:

Sum Points =
CALCULATE (
    SUM ( 'my_data'[Points] ),
    FILTER ( 'my_data', 'my_data'[Team] = EARLIER ( 'my_data'[Team] ) )
)

This particular formula creates a new column named Sum Points that contains the sum of values in the Points column for each unique value in the Team column in the table named my_data.

The following example shows how to use this formula in practice.

Example: How to Use SUM IF in Power BI

Suppose we have the following table in Power BI named my_data that contains information about various basketball players:

Suppose we would like to create a new column that shows the sum of points scored by players on each team.

To do so, click the Table tools tab, then click the New column icon:

Then type the following formula into the formula bar:

Sum Points =
CALCULATE (
    SUM ( 'my_data'[Points] ),
    FILTER ( 'my_data', 'my_data'[Team] = EARLIER ( 'my_data'[Team] ) )
)

A new column named Sum Points will be created that shows the sum of the points values for each team:

From the output we can see:

  • The sum of points value for players on the Mavs team is 75.
  • The sum of points value for players on the Rockets team is 48.
  • The sum of points value for players on the Spurs team is 65.
  • The sum of points value for players on the Hornets team is 31.

Note: You can find the complete documentation for the SUM function in Power BI .

Additional Resources

The following tutorials explain how to perform other common tasks in Power BI:

x