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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
cmacdonald16
New Member

Help with a report

I am building a report 

I have a power BI table called Sessions, A calculated measure called hours, and two calculated columns Week start date, and Week end date. How can i write a query to for a new calculated measure that will give me the sum of hours between Week start date and Week end date

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @cmacdonald16 ,

I created some data:

vyangliumsft_0-1676429307508.png

 

Here are the steps you can follow:

1. Create calculated column.

Week =
WEEKNUM('Table'[Date],1)
Week start date =
 MINX(FILTER(ALL('Table'),
 YEAR('Table'[Date])=YEAR(EARLIER('Table'[Date]))&&
 'Table'[Week]=EARLIER('Table'[Week])),[Date])
Week start date =
 MINX(FILTER(ALL('Table'),
 YEAR('Table'[Date])=YEAR(EARLIER('Table'[Date]))&&
 'Table'[Week]=EARLIER('Table'[Week])),[Date])

vyangliumsft_1-1676429307509.png

2. Create measure.

Measure =
DATEDIFF(
    MAX('Table'[Week start date]),MAX('Table'[Week end date]),HOUR)

3. Result:

vyangliumsft_2-1676429307511.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi  @cmacdonald16 ,

I created some data:

vyangliumsft_0-1676429307508.png

 

Here are the steps you can follow:

1. Create calculated column.

Week =
WEEKNUM('Table'[Date],1)
Week start date =
 MINX(FILTER(ALL('Table'),
 YEAR('Table'[Date])=YEAR(EARLIER('Table'[Date]))&&
 'Table'[Week]=EARLIER('Table'[Week])),[Date])
Week start date =
 MINX(FILTER(ALL('Table'),
 YEAR('Table'[Date])=YEAR(EARLIER('Table'[Date]))&&
 'Table'[Week]=EARLIER('Table'[Week])),[Date])

vyangliumsft_1-1676429307509.png

2. Create measure.

Measure =
DATEDIFF(
    MAX('Table'[Week start date]),MAX('Table'[Week end date]),HOUR)

3. Result:

vyangliumsft_2-1676429307511.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

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.

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.

Top Solution Authors