Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
AdityaPowerBI
Helper II
Helper II

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.

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi @AdityaPowerBI  , 

 

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:

v-yalanwu-msft_0-1620381645663.png

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.  

View solution in original post

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi @AdityaPowerBI  , 

 

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:

v-yalanwu-msft_0-1620381645663.png

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.  

amitchandak
Super User
Super User

@AdityaPowerBI , 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)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors