Search code examples
datepowerbidaxcalculated-columnsrank

Value from next row - DAX


I'm trying to create following calculated column in Power BI data model:

enter image description here

Logic:
Sort dataset based on ID & Start Date and show value from column Status from next row.

(1 ID can have one or more SubIDs)


Solution

  • This will work for a calculated column:

    Expected Result = 
    VAR _start_date = [Start Date]
    VAR _id = [ID]
    VAR _t = FILTER(TableName, [ID] = _id && [Start Date] > _start_date)
    VAR _next_date = MINX(_t, [Start Date])
    RETURN MINX(FILTER(_t, [Start Date] = _next_date), [Status])
    

    enter image description here