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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ksquirt
New Member

Help with DAX, convert SUMIFS

I'm brand new to DAX and reasonably new to Power BI.  I'm trying to convert an Excel formula to Power BI.  Google is not quite helping with one piece.  I need to sum column D when there is a match in column E AND a match in column L.

 

Excel: =SUMIFS(D:D,E:E,E2,L:L,L2)

DAX: Sum of hours = CALCULATE(SUM('Timesheet Data May 2025 2025'[Units],(FILTER(all('Timesheet Data May 2025 2025'[Contractor User Name])),(FILTER(all('Timesheet Data May 2025 2025'[Work Date]))))))

1 ACCEPTED SOLUTION
v-dineshya
Community Support
Community Support

Hi @ksquirt ,

Thank you for reaching out to the Microsoft Community Forum.

 

please follow below steps.

1.  Created sample data based on inputs. refer snap.

vdineshya_0-1748595127692.png

2. Created measure "Sum of Hours Measure", As you are expecting, when User Name and  work date match, it will  sum the units.

 

Sum of Hours Measure =
CALCULATE(
SUM('Timesheet'[Units]),
FILTER(
ALL('Timesheet'),
'Timesheet'[Contractor User Name] = SELECTEDVALUE('Timesheet'[Contractor User Name]) &&
'Timesheet'[Work Date] = SELECTEDVALUE('Timesheet'[Work Date])
)
)
Please refer output snaps and PBIX file.

vdineshya_1-1748595386390.png

In that snap, For Contractor User Name (Alice), the sum of work date for Alice on May 1st 2025 is  9 (2+3+4)=9

The Result is as you expected.

 

If my response has resolved your query, please mark it as the "Accepted Solution" to assist others. Additionally, a "Kudos" would be appreciated if you found my response helpful.

Thank you

 

View solution in original post

6 REPLIES 6
v-dineshya
Community Support
Community Support

Hi @ksquirt ,

Thank you for reaching out to the Microsoft Community Forum.

 

please follow below steps.

1.  Created sample data based on inputs. refer snap.

vdineshya_0-1748595127692.png

2. Created measure "Sum of Hours Measure", As you are expecting, when User Name and  work date match, it will  sum the units.

 

Sum of Hours Measure =
CALCULATE(
SUM('Timesheet'[Units]),
FILTER(
ALL('Timesheet'),
'Timesheet'[Contractor User Name] = SELECTEDVALUE('Timesheet'[Contractor User Name]) &&
'Timesheet'[Work Date] = SELECTEDVALUE('Timesheet'[Work Date])
)
)
Please refer output snaps and PBIX file.

vdineshya_1-1748595386390.png

In that snap, For Contractor User Name (Alice), the sum of work date for Alice on May 1st 2025 is  9 (2+3+4)=9

The Result is as you expected.

 

If my response has resolved your query, please mark it as the "Accepted Solution" to assist others. Additionally, a "Kudos" would be appreciated if you found my response helpful.

Thank you

 

This worked!  Thank you so much!

bhanu_gautam
Super User
Super User

@ksquirt Try Using

 

dax
Sum of hours =
CALCULATE(
SUM('Timesheet Data May 2025 2025'[Units]),
FILTER(
'Timesheet Data May 2025 2025',
'Timesheet Data May 2025 2025'[Contractor User Name] = EARLIER('Timesheet Data May 2025 2025'[Contractor User Name]) &&
'Timesheet Data May 2025 2025'[Work Date] = EARLIER('Timesheet Data May 2025 2025'[Work Date])
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thanks!  It looks like it's adding Units where the User Name is the same, but not the work date.  I need it to sum the units when both matches.

 

What does 'Earlier' do exactly?

@ksquirt 

Returns the current value of the specified column in an outer evaluation pass of the mentioned column.

EARLIER is useful for nested calculations where you want to use a certain value as an input and produce calculations based on that input.

 

Try using

dax
Sum of hours =
CALCULATE(
SUM('Timesheet Data May 2025 2025'[Units]),
FILTER(
'Timesheet Data May 2025 2025',
'Timesheet Data May 2025 2025'[Contractor User Name] = EARLIER('Timesheet Data May 2025 2025'[Contractor User Name]) &&
'Timesheet Data May 2025 2025'[Work Date] = EARLIER('Timesheet Data May 2025 2025'[Work Date])
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






It seems to be adding the units everytime the user name changes.  

 

ksquirt_0-1748544942271.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.