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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
pva
Frequent Visitor

Calculating remaining hours

Hello everyone, I have a table like this where we have how many hours have every sprints and the hours that were done during them.

IdNameTotal hoursDone hours
12Sprint 12717
12Sprint 2119
13Sprint 13412
13Sprint 2239

 

What I want is to create a calculated column that shows how many hours remains from the last sprint. It should be like this:

 

IdProyectNameTotal hoursDone hoursRemainig hours from last srpint
12Sprint 127170 (cause it's the first one)
12Sprint 211910
13Sprint 134120 (cause it's the first one)
13Sprint 223914

Is there any way to do so?

 

Thank you very much!!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @pva ,

 

There seems to be a problem with the data you provided, if grouped by IdProyect and Sprint number fields, the corresponding sum should be 10+12 and 7+4. I did a test and refer to the following code.

code:
Rank =
RANKX (
    FILTER ( ALL ( 'Table' ), [IdProyect] = EARLIER ( [IdProyect] ) ),
    [Sprint number],
    ,
    asc,
    DENSE
)
Remainig hours = 
var tour = CALCULATE(SUM('Table'[Total hours]),ALLEXCEPT('Table','Table'[IdProyect],'Table'[Sprint number]))
var done = CALCULATE(SUM('Table'[Done Hours]),ALLEXCEPT('Table','Table'[IdProyect],'Table'[Sprint number]))
return
if('Table'[Rank]=1, 0 , CALCULATE(tour-done,FILTER(ALL('Table'),'Table'[IdProyect]=EARLIER('Table'[IdProyect]) && 'Table'[Sprint_number]<EARLIER('Table'[Sprint_number]))))

 

If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Stephen


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

4 REPLIES 4
Anonymous
Not applicable

Hi @pva ,

 

There seems to be a problem with the data you provided, if grouped by IdProyect and Sprint number fields, the corresponding sum should be 10+12 and 7+4. I did a test and refer to the following code.

code:
Rank =
RANKX (
    FILTER ( ALL ( 'Table' ), [IdProyect] = EARLIER ( [IdProyect] ) ),
    [Sprint number],
    ,
    asc,
    DENSE
)
Remainig hours = 
var tour = CALCULATE(SUM('Table'[Total hours]),ALLEXCEPT('Table','Table'[IdProyect],'Table'[Sprint number]))
var done = CALCULATE(SUM('Table'[Done Hours]),ALLEXCEPT('Table','Table'[IdProyect],'Table'[Sprint number]))
return
if('Table'[Rank]=1, 0 , CALCULATE(tour-done,FILTER(ALL('Table'),'Table'[IdProyect]=EARLIER('Table'[IdProyect]) && 'Table'[Sprint_number]<EARLIER('Table'[Sprint_number]))))

 

If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Stephen


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

pva
Frequent Visitor

Thanks for your quick response. I made a mistake asking my question. The table that I have is like this.

 

IdProyectSprint numberTotal hoursDone Hours
12Sprint 1107
12Sprint 1124
12Sprint 252
12Sprint 273
13Sprint 12010
13Sprint 197
13Sprint 231

And I'm trying to make a table like this in the report. Example filtered by Proyect 12

IdProyectSprint NumberTotal HoursDone hoursRemaining from past sprint
12Sprint 127130
12Sprint 212514 (27-13)

Do you think is this possible?

 

Thanks again!! @amitchandak I'm trying to clarify it. There is not rank = 1 in the calculated column.

 

@pva , Try like

 

Rank = rankx(filter(Table, [IdProyect] =earlier([IdProyect])) , [Name],,asc,dense)

 

Remainig hours = if([Rank]=1, 0, Sumx(filter( Table,[IdProyect] =earlier([IdProyect]) && [Name] <= earlier([Name]) ),  [Total Hours] - [Done Hours] )

 

Sum up rank one onward

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
amitchandak
Super User
Super User

@pva , Create these columns

 

Rank = rankx(filter(Table, [IdProyect] =earlier([IdProyect])) , [Name],,asc,dense)

 

Remainig hours = if([Rank]=1, 0, [Total Hours] - [Done Hours] )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

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.