Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Assigning flag based on status value

Hi All,

I am stuck in an issue. I have following data. Here I have a order, its entry id , the staff updating the order status and status.

OrderIDEntryIDStaff updatingStatus updated
1011AlexOrdered
1012BenScheduled
1013ChrisAbsent
1014DerenCancelled
1025BenOrdered
1026ChrisScheduled
1027JackRescheduled
1028DerenAbsent
1029AlexCancelled

 

Now I need to find the staff who scheduled the order and assign it a value 1. If staff A has rescheduled and staff B has scheduled an order then staff A should get value 1 and staff B should get value 0. Here is the output I am expecting:

OutputAbsent Count
Alex0
Ben1
Chris0
Derren0
Jack1

 

Thank you in advance.

  • Hi Anonymous  , 

     

    You could create a measure by the following formula:

    flag =
    VAR _MAXid =
        MAXX (
            FILTER ( 'Table', [Staff updating] = MAX ( [Staff updating] ) ),
            [EntryID])
    VAR _Status =
        MAXX (
            FILTER (
                'Table',
                'Table'[EntryID] = _MAXid
                    && [Status updated] IN { "Ordered", "Rescheduled" }),1)
    RETURN   IF ( _Status = 1, 1, 0 )
    

    The final output is shown below:

    Best Regards,
    Community Support Team_ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.  

2 Replies

  • Anonymous , You need have the order id and name in visual,

    You can try a measure like

     

    measure =
    var _Rescheduled = calculate(countrows(Table), filter(Table, Table[Status updated] ="Rescheduled"), allexcept(Table, Table[OrderID]))+0
    var _scheduled = calculate(countrows(Table), filter(Table, Table[Status updated] ="Scheduled"), allexcept(Table, Table[OrderID]))+0
    return
    Switch(
    _Rescheduled > 0 && max(Table[Status updated]) = "Rescheduled",1,
    _scheduled > 0 && max(Table[Status updated]) = "Scheduled",1,
    0)

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi Anonymous  , 

     

    You could create a measure by the following formula:

    flag =
    VAR _MAXid =
        MAXX (
            FILTER ( 'Table', [Staff updating] = MAX ( [Staff updating] ) ),
            [EntryID])
    VAR _Status =
        MAXX (
            FILTER (
                'Table',
                'Table'[EntryID] = _MAXid
                    && [Status updated] IN { "Ordered", "Rescheduled" }),1)
    RETURN   IF ( _Status = 1, 1, 0 )
    

    The final output is shown below:

    Best Regards,
    Community Support Team_ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.