cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

SUMIF Equivalent in DAX

Hi everyone!

 

I have a simple situation here, but can't figure out how to solve it. Imagine the following data model:

 

DAX

 

What I need is a measure (or maybe a column?) that shows the sum of Hours when the Project Company is different from the User company. I tried this:

 

Intercompany Hours = CALCULATE (Sum(Hour[Hours]);Project[Company]<>User[Company])

 

It does not work... I would appreciate any help!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Frequent Visitor

Re: SUMIF Equivalent in DAX

Now it worked! Smiley Happy

 

Intercompany Hours = SUMX(filter('Hour';related(Project[Project_company])<>related(User[User_company]));sum('Hour'[Hours]))

 

solution.png

View solution in original post

6 REPLIES 6
Highlighted
Super User I
Super User I

Re: SUMIF Equivalent in DAX

i dont think your data is modelled correctly.  Firstly how are the joined together?  you need some kind of unique id that flows through to all tables ie. both project and user s should have a project id?  or is that link there?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Frequent Visitor

Re: SUMIF Equivalent in DAX

Hi, thanks for answering!

 

The Hour table is my Fact Table, it has foreign keys from my two Dimension Tables (Project and User) and one measure field (hours). Is that clearer now?

Highlighted
Super User I
Super User I

Re: SUMIF Equivalent in DAX

ah ok makes sense, so what error are you getting?  





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Memorable Member
Memorable Member

Re: SUMIF Equivalent in DAX

I would think you would want to change to SUMX and use RELATED

 

CALCULATE( 
   SUMX (Hours, Hours[Hours]),
   RELATED(Project[Company]) <> RELATED(User[Company]) 
)

 

Hope this helps,

David 

Highlighted
Frequent Visitor

Re: SUMIF Equivalent in DAX

Hi David and Vanessa,

 

Here is a link to my example file: http://www.syscope.com.br/files/example.zip

 

 

Here is the data model:

data_model.png

 

Here is the data, my expression should show the 10 hours below (where the user company is different from the project company):

 

data_example.png

 

This is the error I got with my formula:

error_marcelo.png

 

And David, this is the error I got from your formula:

 

error_david.png

 

Highlighted
Frequent Visitor

Re: SUMIF Equivalent in DAX

Now it worked! Smiley Happy

 

Intercompany Hours = SUMX(filter('Hour';related(Project[Project_company])<>related(User[User_company]));sum('Hour'[Hours]))

 

solution.png

View solution in original post

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors