Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SUM IF in Power BI

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?

like image 314
Shoaib Maroof Avatar asked Jun 19 '18 15:06

Shoaib Maroof


1 Answers

Yes. There are two basic approaches to this.

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

or

SUMX(FILTER(TableName, TableName[Country] = "Italy"), TableName[Hours])
like image 109
Alexis Olson Avatar answered Oct 01 '22 02:10

Alexis Olson