Forum Discussion
Getting row values from another row based on associated texts
Hi
I am trying to get the calculated value based on these relationships:
Project Initiation Phase - M02
Scope and Feasibility - M04
Design Phase - M12
Delivery Phase - M23
Handover/Takeover - M24
Project Close - M 25
Sample data on different projects with the required calculated values is as shown:
| ProjectName | ObjectName | ForecastFinishDate | ActualFinishDate | Calculated value |
| 1000 | Delivery Phase | 20/05/2020 | 27/08/2020 | 30/04/2020 |
| 1000 | Design Phase | 14/06/2019 | 11/06/2019 | 28/05/2019 |
| 1000 | Hand Over/Take Over Phase | 10/12/2019 | 4/02/2021 | 4/02/2021 |
| 1000 | M02 | 00/00/0000 | 5/02/2018 | |
| 1000 | M04 | 00/00/0000 | 12/07/2018 | |
| 1000 | M12 | 00/00/0000 | 28/05/2019 | |
| 1000 | M23 | 00/00/0000 | 30/04/2020 | |
| 1000 | M24 | 00/00/0000 | 4/02/2021 | |
| 1000 | M25 | 00/00/0000 | 4/02/2021 | |
| 1000 | Project Close Phase | 10/12/2019 | 00/00/0000 | 4/02/2021 |
| 1000 | Project Initiation Phase | 23/01/2018 | 5/02/2018 | 5/02/2018 |
| 1000 | Scope and Feasibility Phase | 28/05/2018 | 12/07/2018 | 12/07/2018 |
| 2000 | Delivery Phase | 25/11/2019 | 20/11/2019 | 20/11/2019 |
| 2000 | Design Phase | 10/12/2016 | 6/04/2018 | 6/04/2018 |
| 2000 | Hand Over/Take Over Phase | 30/09/2019 | 23/07/2020 | 4/08/2020 |
| 2000 | M02 | 00/00/0000 | 1/06/2015 | |
| 2000 | M04 | 00/00/0000 | 22/10/2016 | |
| 2000 | M12 | 00/00/0000 | 6/04/2018 | |
| 2000 | M23 | 00/00/0000 | 20/11/2019 | |
| 2000 | M24 | 00/00/0000 | 4/08/2020 | |
| 2000 | M25 | 00/00/0000 | 00/00/0000 | |
| 2000 | Project Close Phase | 22/10/2020 | 00/00/0000 | 00/00/0000 |
| 2000 | Project Initiation Phase | 1/06/2015 | 1/06/2015 | 1/06/2015 |
| 2000 | Scope and Feasibility Phase | 22/10/2016 | 22/10/2016 | 22/10/2016 |
| 3000 | … | … | … | … |
| 3000 | … | … | … | … |
Hi Anonymous
Try this new code to add a column:
Calculated Value = VAR _A = SWITCH ( TRUE (), [ObjectName] = "Project Initiation Phase", "M02 - Approve Fee Proposal", [ObjectName] = "Scope and Feasibility", "M04 - Approve Phase 1 Report", [ObjectName] = "Design Phase", "M12 - Approve Phase 2 Report", [ObjectName] = "Delivery Phase", "M23 - Issue Certificate of Completion", [ObjectName] = "Hand Over/Take Over Phase", "M24 - Recommend Hand Over Acceptance", [ObjectName] = "Project Close Phase", "M25 - Reduce PO Values To Zero", [ObjectName] = "Scope and Feasibility Phase", "Scope and Feasibility Phase", BLANK () ) VAR _B = IF ( ISBLANK ( _A ), BLANK (), CALCULATE ( MAX ( 'Table'[ActualFinishDate] ), FILTER ( ALL ( 'Table' ), [ObjectName] = _A && [ProjectName] = EARLIER ( 'Table'[ProjectName] ) ) ) ) RETURN IF ( ISBLANK ( _B ), CALCULATE ( MAX ( 'Table'[FinishDate] ), FILTER ( ALL ( 'Table' ), [ObjectName] = _A && [ProjectName] = EARLIER ( 'Table'[ProjectName] ) ) ), _B )Output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
12 Replies
- VahidDMSuper User
Hi Anonymous
Can you post sample data as text and expected output?
Not enough information to go on, and it's not clear for me!
please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Appreciate your Kudos!!
LinkedIn:www.linkedin.com/in/vahid-dm/- AnonymousNot applicable
ProjectName ObjectName ForecastFinishDate ActualFinishDate Calculated value 1000 Delivery Phase 20/05/2020 27/08/2020 30/04/2020 1000 Design Phase 14/06/2019 11/06/2019 28/05/2019 1000 Hand Over/Take Over Phase 10/12/2019 4/02/2021 4/02/2021 1000 M02 00/00/0000 5/02/2018 1000 M04 00/00/0000 12/07/2018 1000 M12 00/00/0000 28/05/2019 1000 M23 00/00/0000 30/04/2020 1000 M24 00/00/0000 4/02/2021 1000 M25 00/00/0000 4/02/2021 1000 Project Close Phase 10/12/2019 00/00/0000 4/02/2021 1000 Project Initiation Phase 23/01/2018 5/02/2018 5/02/2018 1000 Scope and Feasibility Phase 28/05/2018 12/07/2018 12/07/2018 2000 Delivery Phase 25/11/2019 20/11/2019 20/11/2019 2000 Design Phase 10/12/2016 6/04/2018 6/04/2018 2000 Hand Over/Take Over Phase 30/09/2019 23/07/2020 4/08/2020 2000 M02 00/00/0000 1/06/2015 2000 M04 00/00/0000 22/10/2016 2000 M12 00/00/0000 6/04/2018 2000 M23 00/00/0000 20/11/2019 2000 M24 00/00/0000 4/08/2020 2000 M25 00/00/0000 00/00/0000 2000 Project Close Phase 22/10/2020 00/00/0000 00/00/0000 2000 Project Initiation Phase 1/06/2015 1/06/2015 1/06/2015 2000 Scope and Feasibility Phase 22/10/2016 22/10/2016 22/10/2016 3000 … … … … 3000 … … … … - AnonymousNot applicable
Essentially, I am trying to get the actual finish date from all the M labels i.e. M02, M04, M23 etc into the various phases. One example would be getting the M02 -actual finished into the project initation phase for project name 1000- so it would be 05/02/2018 as the newly calculated field in Project Initiation Phase.
Hope this is clear.