Forum Discussion
How Do I Calculate Project Activity Back and Forth
I am trying to calculate the time duration a project stays in any given stage. The problem is, that a project can jump back and forth between stages and departments depending of the scope of the project.
How would I calculate total time in each Stage AND how many times does a project enter/leave a stage? I will need to know the duration of time within each Stage instance.
Any help would be greatly appreciated!
Below is a table table of 1 project. Currently, all projects are housed in one large status table. Everytime an action occurs, a new Status_ID is created and the progress is added.
| Status_Id | ProjectId | StageId | Created | Note | Parent Status_Id | Stage_Name |
| 3814 | 1 | 1031 | 2/10/2022 | 2.10.22 Saved | 3811 | Tech Review |
| 3835 | 1 | 1031 | 2/10/2022 | 2.10.22. Saved | 3829 | Tech Review |
| 3829 | 1 | 1031 | 2/10/2022 | 2.10.22 update released drawings. | 3814 | Tech Review |
| 3811 | 1 | 1031 | 2/10/2022 | 2.10.22 update released drawings | 3727 | Tech Review |
| 3837 | 1 | 1047 | 2/10/2022 | 2.10.22 Please release to production | 3835 | Production |
| 3727 | 1 | 1031 | 2/9/2022 | 2.10.22 update released drawings | 3688 | Tech Review |
| 3688 | 1 | 1031 | 2/8/2022 | 2.8.22 update released drawings | 3675 | Tech Review |
| 3675 | 1 | 1031 | 2/8/2022 | 2.8.22. Proofsent back | 3672 | Tech Review |
| 3672 | 1 | 1031 | 2/8/2022 | 2.8.22 updated proof | 3540 | Tech Review |
| 3703 | 1 | 1047 | 2/8/2022 | 2.8.22: Please release to production | 0 | Production |
| 3540 | 1 | 1031 | 2/4/2022 | 2.4.22. Saved | 3484 | Tech Review |
| 3482 | 1 | 1031 | 2/3/2022 | 2.3.22 Saved | 3481 | Tech Review |
| 3484 | 1 | 1031 | 2/3/2022 | 2.3.22 saved | 3482 | Tech Review |
| 3481 | 1 | 1023 | 2/3/2022 | 2.3.22 2nd proof | 3396 | Review Proof |
| 3396 | 1 | 1031 | 2/2/2022 | 2.2.22 Sent proof back | 3391 | Tech Review |
| 3391 | 1 | 1031 | 2/2/2022 | 2.2.22 update 2nd proof | 3227 | Tech Review |
| 3222 | 1 | 1022 | 1/28/2022 | 1.28.22: Please see changes | 0 | Graphics |
| 3227 | 1 | 1031 | 1/28/2022 | 1.27.22 update 1st proof | 3222 | Tech Review |
| 3151 | 1 | 1031 | 1/27/2022 | 1.27.22 update 1st proof | 3128 | Tech Review |
| 3177 | 1 | 1031 | 1/27/2022 | 1.27.22 update 1st proof | 3151 | Tech Review |
| 3128 | 1 | 1031 | 1/27/2022 | 1.27.22 update 1st proof | 2871 | Tech Review |
| 3187 | 1 | 1087 | 1/27/2022 | 1.27.22 1st proof | 3184 | Review Proof |
| 3184 | 1 | 1031 | 1/27/2022 | 1.27.22 Internal Proofing | 3177 | Tech Review |
| 2871 | 1 | 1031 | 1/21/2022 | 1.26.22 internal proofing | 2294 | Tech Review |
| 2294 | 1 | 1021 | 1/7/2022 | 1.20.22: Please note | 0 | Graphics |
| 879 | 1 | 1128 | 12/1/2021 | 0 | Follow up Estimators | |
| 773 | 1 | 1124 | 11/29/2021 | Please revise the quote | 0 | Estimating |
| 278 | 1 | 1124 | 11/10/2021 | compile a quote | 0 | Estimating |
Hi Anonymous ,
Reaching this is more difficult. You can try the following steps.
First create an index column.
Create a calculated column to calculate the number of times the current row belongs to tech review.How many times = VAR _maxIndexOf_ProjectAndStage = MAXX ( FILTER ( 'Table', 'Table'[ProjectId] = EARLIER ( 'Table'[ProjectId] ) && [Stage_Name] = "Tech Review" ), [Index] ) VAR _maxIndexOfProject = MAXX ( FILTER ( 'Table', 'Table'[ProjectId] = EARLIER ( 'Table'[ProjectId] ) ), [Index] ) VAR _countNotTechReview = COUNTROWS ( FILTER ( 'Table', [Index] > EARLIER ( 'Table'[Index] ) && [Stage_Name] <> "Tech Review" ) ) RETURN IF ( [Stage_Name] = "Tech Review", _countNotTechReview - ( _maxIndexOfProject - _maxIndexOf_ProjectAndStage - 1 ) )
Create another column to calculate how many days the current tech review has consumed.length of XXX calendar days = VAR _start = MAXX ( FILTER ( 'Table', [ProjectId] = EARLIER ( 'Table'[ProjectId] ) && [How many times] = EARLIER ( 'Table'[How many times] ) ), [Created] ) VAR _end = MINX ( FILTER ( 'Table', [ProjectId] = EARLIER ( 'Table'[ProjectId] ) && [How many times] = EARLIER ( 'Table'[How many times] ) ), [Created] ) RETURN IF ( [Stage_Name] = "Tech Review", VALUE ( _start - _end ) + 1 )Finally, in the visual chart, seperate the maximum number of times for the current project id and average the number of days using the following formula.
average length of XXX calendar days = AVERAGEX(VALUES('Table'[length of XXX calendar days]),[length of XXX calendar days])Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
7 Replies
- v-chenwuz-msft
Community Support
Hi Anonymous ,
The duration can be referred to this formula.
Duration = value(MAX('Table'[Created])-MIN('Table'[Created]))+1
Not sure what your standard is for calculating entry and leave procedures. Can you give some idea of what the desired outcome would look like?How to Get Your Question Answered Quickly - Microsoft Power BI Community
Best RegardsCommunity Support Team _ chenwu zhu
- AnonymousNot applicable
I need to know how many times a project has to have the same step repeated in the production process.
I am trying to get to the level that says:
Tech review had to be started 6 seperate times. Each instance had an average length of XXX calendar days.
- v-chenwuz-msft
Community Support
Hi Anonymous ,
Reaching this is more difficult. You can try the following steps.
First create an index column.
Create a calculated column to calculate the number of times the current row belongs to tech review.How many times = VAR _maxIndexOf_ProjectAndStage = MAXX ( FILTER ( 'Table', 'Table'[ProjectId] = EARLIER ( 'Table'[ProjectId] ) && [Stage_Name] = "Tech Review" ), [Index] ) VAR _maxIndexOfProject = MAXX ( FILTER ( 'Table', 'Table'[ProjectId] = EARLIER ( 'Table'[ProjectId] ) ), [Index] ) VAR _countNotTechReview = COUNTROWS ( FILTER ( 'Table', [Index] > EARLIER ( 'Table'[Index] ) && [Stage_Name] <> "Tech Review" ) ) RETURN IF ( [Stage_Name] = "Tech Review", _countNotTechReview - ( _maxIndexOfProject - _maxIndexOf_ProjectAndStage - 1 ) )
Create another column to calculate how many days the current tech review has consumed.length of XXX calendar days = VAR _start = MAXX ( FILTER ( 'Table', [ProjectId] = EARLIER ( 'Table'[ProjectId] ) && [How many times] = EARLIER ( 'Table'[How many times] ) ), [Created] ) VAR _end = MINX ( FILTER ( 'Table', [ProjectId] = EARLIER ( 'Table'[ProjectId] ) && [How many times] = EARLIER ( 'Table'[How many times] ) ), [Created] ) RETURN IF ( [Stage_Name] = "Tech Review", VALUE ( _start - _end ) + 1 )Finally, in the visual chart, seperate the maximum number of times for the current project id and average the number of days using the following formula.
average length of XXX calendar days = AVERAGEX(VALUES('Table'[length of XXX calendar days]),[length of XXX calendar days])Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.