SUM IF in Power BI

Shoaib Maroof picture Shoaib Maroof · Jun 19, 2018 · Viewed 20.3k times · Source

Is it possible to SUM on conditions in Power BI?

I have a column that contains the values UK and Italy alongside other columns: employee and hours spent.

I want to make a measure to show total hours spent by an employee in Italy and another to show total hours spent by an employee in UK.

I am having no luck with the DAX language. Can anyone help?

Answer

Alexis Olson picture Alexis Olson · Jun 19, 2018

Yes. There are two basic approaches to this.

CALCULATE(SUM(TableName[Hours]), TableName[Country] = "Italy")

or

SUMX(FILTER(TableName, TableName[Country] = "Italy"), TableName[Hours])