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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

First sales date of a customer

Hi All, 

 

I need the first salesdate of every customer in my data.

This first sales must contain the category code "beachflags" and have at least an amount (salesamount) of 750. 

 

How can i make this in DAX with the variables 

custnr

catogrycode

salesamount 

salesdate

 

I hope someone have a solution

1 ACCEPTED SOLUTION

@Anonymous 

 

Assuming you are trying to create a custom column and not a measure, this probably should work. 

 

First Sales Date =
// Return true if it is a first order
Sales[salesdate] = 
CALCULATE (
    MIN ( Sales[salesdate] ),
    ALL ( Sales),
    Sales[custnr]  = Earlier(Sales[custnr] ),
    Sales[catogrycode] = "beachflags",
    Sales[salesamount] >= 750
)

View solution in original post

7 REPLIES 7
OwenAuger
Super User
Super User

@Anonymous 

You can create a calculated column like this (adjust column names as required):

First Sales Date =
CALCULATE (
    MIN ( Sales[salesdate] ),
    ALLEXCEPT ( Sales, Sales[custnr] ),
    Sales[catogrycode] = "beachflags",
    Sales[salesamount] >= 750
)

This formula retains just the customer filter from the current row, then also applies the category and amount filters.

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn
Anonymous
Not applicable

@OwenAuger 

ok thanks! 

 

Do you also have a solution for the following: 

all the customers where the very first salesorder contains beachflags and an amount > 750

hi, @Anonymous 

Use ALL instead of ALLEXCEPT

Spoiler
Measure =
CALCULATE (
    MIN ( Sales[salesdate] ),
    ALL ( Sales ),
    Sales[catogrycode] = "beachflags",
    Sales[salesamount] >= 750
)

 If not your case, please share your sample data and expected output.

 

Best Regards,
Lin

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hello @v-lili6-msft 

I only need the customers where the first order ever of this customer, contains beachflags and an amount above 750.

 

image.png

@Anonymous  - I see there have been a few posts on this.

Just clarifying the requirements.

Do you want to identify all customers whose first ever order was "beachflags" and >=750, and then include all rows relating to those customers? 

For example, in the table you posted, you want to include all rows for Custno=4 since that customer meets the condition?

 

Also, do you want to create a calculated column flagging the relevant rows, or create a filter on the fly to use within a measure?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn
Anonymous
Not applicable

Whose first beachflags order was >= 750. 

And i want those customers in a matrix, doesn't matter if it works with a measure or calculated column

@Anonymous 

 

Assuming you are trying to create a custom column and not a measure, this probably should work. 

 

First Sales Date =
// Return true if it is a first order
Sales[salesdate] = 
CALCULATE (
    MIN ( Sales[salesdate] ),
    ALL ( Sales),
    Sales[custnr]  = Earlier(Sales[custnr] ),
    Sales[catogrycode] = "beachflags",
    Sales[salesamount] >= 750
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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