Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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/Takeov...
  • VahidDM's avatar
    VahidDM
    4 years ago

    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/