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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ironboy0423
Helper I
Helper I

How to calculate the sum of a row for distinct date only

Hello, I am currently updating this dax to make sure that I am getting the correct value from table2durationhours column - this is a calculated column from another table. However, when I use this dax it sum up all the rows from table2durationhours resulting to very large hours for 1 date. For example, there are multiple rows for 06/05/2022 and it sum up all of these, and it should be for 1 row only. Please see below dax I am currently using:

 

Week1Duration = VAR SelectedWeekStart = SELECTEDVALUE('01_Date'[Start of Week]) VAR Week1StartDate = CALCULATE(MIN('01_Date'[CalendarDate]), '01_Date'[Start of Week] = SelectedWeekStart) VAR Week1EndDate = Week1StartDate + 6 RETURN CALCULATE( SUM(FactTable[Table2DurationHours]), 'FactTable'[Date] >= Week1StartDate && 'FactTable'[Date] <= Week1EndDate )


Week2Duration = CALCULATE(SUM('FactTable'[Table2DurationHours]), REMOVEFILTERS('01_Date'[Start of Week]), '01_Date'[Week ID] = MAX('01_Date'[Week ID]) + 1)

 

Example table:

 

ironboy0423_0-1691587112473.png

 

2 REPLIES 2
eliasayyy
Memorable Member
Memorable Member

hello it looks like table2duration already sums up by date the value of duration hours , so when you are doing the sum of table2 , you are actually summig up the total again so maybe just use max?

Hello, yup, right. I am doing the max calculation for week 2. However, it still returns a very large values.

What is the best way to filter each max value per date?

 

ReckonWeek2DurationHours = CALCULATE(SUMX('FactTable', MAX(TimeEntry[ReckonDurationHours])),
        REMOVEFILTERS('01_Date'[Start of Week]), '01_Date'[Week ID] = MAX('01_Date'[Week ID]) + 1)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.