Forum Discussion

darianle's avatar
darianle
Regular Visitor
3 years ago
Solved

Find the Nearest Value One column to Another Based on ID

Good Morning,   I have been wrapping my head around this for days—numerous searches to no avail.   I have three columns:   ID, Enter, and Exit For Each ID,  if there is an Enter Time, there shou...
  • AlB's avatar
    3 years ago

    Hi darianle 

    Try this calculated column:

    ClosestExit = 
    VAR enter_ = Table1[Enter]
    RETURN
        TOPN (
            1,
            CALCULATETABLE (
                DISTINCT ( Table1[Exit] ),
                ALLEXCEPT ( Table1, Table1[NumberID] ),
                Table1[Exit] >= enter_
            ),
            Table1[Exit] - enter_, ASC
        )

     

    Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.