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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
ironboy0423
Helper I
Helper I

DAX: How to calculate the sum of a column/rows for the following week

Hello Community, I have a power bi dax that calculates the hours based on selected start of week. I am currently getting the correct value for week 1, however, week 2 or the following week returns the total sum of entire rows. I select the start of week using a slicer. Below is the dax I am currently using for week 1 and week 2:

 

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[Duration]), 'FactTable'[Date] >= Week1StartDate && 'FactTable'[Date] <= Week1EndDate )

 

 

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

1 ACCEPTED SOLUTION

It works when I organize the relationship between tables, thank you

View solution in original post

4 REPLIES 4
ironboy0423
Helper I
Helper I

Hi @Anonymous yes it is, this is the current result I am getting so far:

 

ironboy0423_0-1691555855704.png

 

tamerj1
Super User
Super User

Hi @ironboy0423 
Are the date table and the fact table connected? How does your visual look like?

It works when I organize the relationship between tables, thank you

And to add to this, yes it is connected but not active, when I activate the relationship, it will introduce ambuigity to other fact table that is currently connected to date table

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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