Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Show Last Value based on Flag

Hi all,   I have this table:   and I want to create a flag that shows the last value based on the last StartDate value and the last EndDate value to show me the last success status.  The...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    For your case, it's suggested that you create an index column group by Pipeline name in Power Query first.

    Steps of add the index column:

    Click "Close&Apply" and go back to Power BI Desktop.

    Then create a calculated column.

    flag = var _max=CALCULATE(MAX('Table'[Index]),FILTER('Table',[PipelineName]=EARLIER('Table'[PipelineName])))
    var _status=CALCULATE(MAX('Table'[Status]),FILTER('Table',[PipelineName]=EARLIER('Table'[PipelineName])&&[Index]=_max))
    return IF(_max=[Index],SWITCH(_status,"Succeeded",3,"InProgress",2),0)

     

     

     

    Best Regards,

    Stephen Tao

     

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