Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Set flag on grouped order rows based on final order status

Hi I have a table with the first 4 columns.  I would like to set a flag that indicates if an order has ended in a 'Reject' status.  So if the last order status says 'Reject' flag it as Rejected.  I can do this in SQL and upload to Power BI but struggling to write in DAX.  Help is appreciated.

 

Order IDStatus StartStatus CompleteOrder Status

(Added Column)

isRejected

12017-08-212017-08-211 - Originator Matches to PO1
12017-08-212017-08-212b - A/P Enters Invoice1
12017-08-212017-08-214 - Capital Manager Approval1
12017-08-212017-08-211 - Originator Matches to PO1
12017-08-212017-08-211 - Originator Matches to PO1
12017-08-212017-08-227 - Reject1
22017-08-212017-08-211 - Originator Matches to PO0
22017-08-212017-08-212b - AP Enters Invoice0
22017-08-212017-08-233 - Property Accountant Review0
22017-08-232017-08-235 - Regional Manager Approval0
22017-08-232017-08-237 - Approve0
  • Hi Anonymous 

     

    Try this.

     

    isRejected = 
    VAR _reject =  
        CALCULATE( 
            COUNTROWS( 'Table' ), 
            ALLEXCEPT( 'Table', 'Table'[Order ID] ), 
            SEARCH( "Reject", 'Table'[Order Status] , 1, 0 ) > 0  
        )
    RETURN 
        IF( _reject > 0, 1, 0 )

     

    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    Mariusz Repczynski



1 Reply

  • Mariusz's avatar
    Mariusz
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 

     

    Try this.

     

    isRejected = 
    VAR _reject =  
        CALCULATE( 
            COUNTROWS( 'Table' ), 
            ALLEXCEPT( 'Table', 'Table'[Order ID] ), 
            SEARCH( "Reject", 'Table'[Order Status] , 1, 0 ) > 0  
        )
    RETURN 
        IF( _reject > 0, 1, 0 )

     

    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    Mariusz Repczynski