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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request 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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.