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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ciken
Resolver I
Resolver I

Determining first date a specific product was purchased

I'm trying to determine if there is a way to write a formula on my Customer table to look for the first time a product category was purchased. For example, Jim Smith first purchased product A on 1/1/2010 but I'm interested in knowing IF AND WHEN Jim Smith purchased Product C. I've got the first time purchase column completed: 

FirstTimePurchase = CALCULATE(MIN('Operations: Orders'[Order Date]),ALLEXCEPT('Operations: Orders',Customer[CustomerID]))

 

But I don't know how to add the filter to then determine MIN order with Subscripton Type = "Autorefill".

 

HELP??

How the customer table currently looksHow the customer table currently looks

3 REPLIES 3
v-alq-msft
Community Support
Community Support

Hi, @ciken 

 

Based on your description, I created data to reproduce your scenario.

Table:

b1.png

 

You may create two measures as below.

FirstTimePurchaseA autorefill = 
CALCULATE(
    MIN('Operations: Orders'[Order Date]),
    FILTER(
        ALLSELECTED('Operations: Orders'),
    'Operations: Orders'[CustomerID] = SELECTEDVALUE('Operations: Orders'[CustomerID])&&
    'Operations: Orders'[Subscription type] = "Autorefill"
    )
)
PurchaseC autorefill Date = 
var result = 
CONCATENATEX(
    FILTER(
        ALLSELECTED('Operations: Orders'),
        'Operations: Orders'[CustomerID] = SELECTEDVALUE('Operations: Orders'[CustomerID])&&
        'Operations: Orders'[Product] = "C"&&
        'Operations: Orders'[Subscription type] = "Autorefill"
    ),
    'Operations: Orders'[Order Date],
    ","
)
return
IF(
    ISBLANK(result),
    "no purchase Product C",
    result
)

 

Result:

b2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks @v-alq-msft ,

The problem lies in that my subscription type is in a different table than my order date. My order date is in 'Operations: Orders' and my subscription type (and all product data) is in a table called 'Operations: Orders Shopping Cart'. When I try to write either of the codes below it is not allowing me to pull data from a second table into the measurement.  First time purchase2.jpg

Greg_Deckler
Super User
Super User

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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