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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Flag Occurrences after specific date

Hello,

 

I Have created some dummy data to simulate a problem I'm trying to solve in Power BI Desktop: 

 

mpogue_2-1618926378775.png

 

I am trying to create a column which flags "TRUE" every time a customer orders an Item that is not an Apple, only after they have 1 order which contains an Apple.

 

For example, Jim has ordered Pair on 4/27, Apple on 5/2, Pair on 5/10, Apple on 5/13, and Orange on 5/15. I would only like to flag the column TRUE, on the instance where Jim has ordered Pair on 5/10 and Orange on 5/15. 

 

Also if the same customer has 2 orders on the same day, one containing Apple and one containing a different item. I would like to flag the order that contains the different item. For example on 4/28 Joe has made one order of Apple and one order of Banana. I would Like to flag the Banana order on 4/28 as TRUE, and every other order that is not an Apple from thereon forward. 

 

Thank you very much, your help is much appreciated.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Based on your description, you can create a calculated column as follows.

Column =
VAR x1 =
    SUMMARIZE (
        FILTER ( ALL ( 'Orders' ), [item Name ] = "Apple" ),
        [Customer Name ]
    )
RETURN
    IF (
        [Customer Name ]
            IN x1
                && [item Name ] <> "Apple"
                && [Order ID ]
                    > MINX (
                        FILTER ( ALL ( 'Orders' ), [Customer ID ] = EARLIER ( Orders[Customer ID ] ) ),
                        [Order ID ]
                    ),
        "True"
    )

Result:

v-yuaj-msft_0-1619079602409.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

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
Anonymous
Not applicable

Hi @Anonymous ,

 

Based on your description, you can create a calculated column as follows.

Column =
VAR x1 =
    SUMMARIZE (
        FILTER ( ALL ( 'Orders' ), [item Name ] = "Apple" ),
        [Customer Name ]
    )
RETURN
    IF (
        [Customer Name ]
            IN x1
                && [item Name ] <> "Apple"
                && [Order ID ]
                    > MINX (
                        FILTER ( ALL ( 'Orders' ), [Customer ID ] = EARLIER ( Orders[Customer ID ] ) ),
                        [Order ID ]
                    ),
        "True"
    )

Result:

v-yuaj-msft_0-1619079602409.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

@Anonymous , Try a new column like

 

new column =
var _max = maxx(filter(orders, [customerID] = earlier([customerID]) && [order ID] <earlier([order ID])), [order ID])
var _maxItem = countx(filter(orders, [customerID] = earlier([customerID]) && [order ID] = _max && [ItemName] ="Apple" ), [order ID]) +0
return
if( [ItemName] ="Apple" && _maxItem=0 , True(), blank())

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.