Forum Discussion

EvanGetsItDone's avatar
2 years ago
Solved

Get the value of the previous ID dynamically based on sequence ID/ Rank ID

Hello,  How can we be able to get the value of the previous ID dynamically? I have values that are based on sequence ID or Rank ID. and I want to get the value of the previous ID of the selected ID...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, EvanGetsItDone 

    If you want to filter dynamically with slicers, you'll need to create a metric instead of the original ID. Start by creating two calculated columns to calculate the data in the previous row.

    Previous ID = 
    VAR CurrentID = 'Table'[ID]
    VAR PreviousID = CALCULATE(MAX('Table'[ID]), FILTER('Table', 'Table'[ID] < CurrentID))
    RETURN 
    PreviousID
    
    Previous Value = 
    VAR CurrentID = 'Table'[ID]
    VAR PreviousID = CALCULATE(MAX('Table'[ID]), FILTER('Table', 'Table'[ID] < CurrentID))
    VAR PreviousValue = LOOKUPVALUE('Table'[Value], 'Table'[ID], PreviousID)
    RETURN PreviousValue

     

    Next, create a new table.

     

    Then create a measure that when the ID is selected, the row data disappears

    SelectID = 
    VAR _slicer = MAX('Table 2'[ID])
    RETURN
    IF(MAX('Table'[ID])<>_slicer,MAX('Table'[ID]),BLANK())

     

    How to Get Your Question Answered Quickly 

    Best Regards

    Yongkang Hua

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.