Forum Discussion

caruso1058's avatar
caruso1058
Icon for Microsoft Employee rankMicrosoft Employee
6 years ago
Solved

Searching a Column to Return Value

Hello I have a a Table with several iterations of part numbers. If a part is still in development then I need to return the latest part number.  If the part is no longer in Development then return ...
  • mahoneypat's avatar
    6 years ago

    This is one way to do this in a calculated column expression. Note that you can choose to return any of the last 3 variables for different results (for example, the latest version, Dev vs Prod, or It's the last T or F).

    Latest Version =
    VAR thisversion = Parts[PN_Suffix]
    VAR latestproduction =
        CALCULATE (
            MAX ( Parts[PN_Suffix] ),
            ALLEXCEPT ( Parts, Parts[PN_Base] ),
            FILTER ( ALL ( Parts[PN_Suffix] ), VALUE ( Parts[PN_Suffix] ) < 900 )
        )
    VAR latestdev =
        CALCULATE (
            MAX ( Parts[PN_Suffix] ),
            ALLEXCEPT ( Parts, Parts[PN_Base] ),
            FILTER ( ALL ( Parts[PN_Suffix] ), VALUE ( Parts[PN_Suffix] ) > 900 )
        )
    VAR latest =
        IF ( ISBLANK ( latestproduction ), latestdev, latestproduction )
    VAR islatest = thisversion = latest
    VAR prodordev =
        IF ( ISBLANK ( latestproduction ), "Development", "Production" )
    RETURN
        latest

    If this works for you, mark it as the solution. Praise is also appreciated. Please let me know if you don't.

    Best regards

    Pat