cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
8048237
Frequent Visitor

Identify Sample Orders that led to a Purchase

Hi,
I am trying to find a way to identify if any orders were placed after a customer was sent samples of a product. Orders are categorised as Samples or Purchases.

Samples: Order Price = 0

Purchase: Order Price > 0

What I'm looking for is an order with the same combination of Item Number and Customer, placed after a sample order is placed. If such an order exists then the "Purchase on Sample?" column should indicate "Yes".

 

This is my sample table.

Order NumberItem NumberCustomerOrder DateOrder PriceIs Sample?Purchase on Sample?
110A01/01/20230YesYes
212A02/01/20230YesNo
310A03/01/202350NoNo
415B04/01/2023400NoNo
514B05/01/20230YesNo
612B06/01/2023350NoNo

 

Example: For Sample Order [Order Number 1], we have Item and customer combination {10, A} on 01/01/2023. We have another order [Order Number 3] with the same Item-customer combination with Order Price >0. Hence, the "Purchase on Sample?" column for [Order number 1] should be marked as "Yes".

For [Order Numbers 2 & 6], The item number is same but the customer is different. So we cannot say that the Sample order led to a purchase from the customer.

 

Please help me write the DAX for this. I would prefer using calculated column.

All help is appreciated.

Thank You

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @8048237 
The two calculated columns can be:

1.png

Is Sample? = 'Table'[Order Price] = 0
Purchase on Sample? = 
IF ( 
    'Table'[Is Sample?],
    NOT ISEMPTY (
        CALCULATETABLE ( 
            'Table',
            ALLEXCEPT ( 'Table', 'Table'[Item Number], 'Table'[Customer] ),
            'Table'[Order Price] > 0
        )
    )
)

 

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

Hi @8048237 
The two calculated columns can be:

1.png

Is Sample? = 'Table'[Order Price] = 0
Purchase on Sample? = 
IF ( 
    'Table'[Is Sample?],
    NOT ISEMPTY (
        CALCULATETABLE ( 
            'Table',
            ALLEXCEPT ( 'Table', 'Table'[Item Number], 'Table'[Customer] ),
            'Table'[Order Price] > 0
        )
    )
)

 

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors