Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Spyker
New Member

SUMIFS equivalent for calculated column

Hi,

I am attempting to recreate a simple SUMIFS formula in PowerBI. The attached picture is an example of the table I want, with the column to be calculated in red and the SUMIFS formula used for that column shown. Basically, I want to know how many hours a specific user worked in a specific week, and I need that figure to be in on that data entry (row).

 

SUMIFS Example.png

 

I have had a good look online and none of the solutions seems to work with me. The following seems to get close, but I assume the issue is not being able to differentiate between a column and a cell as I can in excel with the sumifs formula.

Total hours = CALCULATE(SUM('Table'[Hours]),'Table'[User]='Table'[User], 'Table'[Week Number]= 'Table'[Week Number])

 

The actual data set to be used it fairly large and I eventually want to use the column in a gantt chart so I believe I need to use a calculated column for this. Is this even possible? Please let me know if I havn't explained anything very well.

 

Thanks in advance.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Spyker Try:

Column = 
  VAR __User = [User]
  VAR __Week = [Week Number]
  VAR __Table = FILTER('Table',[User] = __User && [Week Number] = __Week)
RETURN
  SUMX(__Table,[Hours])

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@Spyker Try:

Column = 
  VAR __User = [User]
  VAR __Week = [Week Number]
  VAR __Table = FILTER('Table',[User] = __User && [Week Number] = __Week)
RETURN
  SUMX(__Table,[Hours])

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Wow, worked perfectly! Thanks very much for your accurate and fast response.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.