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

New vs Existing Customer Based on Sales created date and salesperson

Hello

 

Please help me out here

I'm creating a calculated column with the Customer First Sales Date and in the case where that same customer has a different salesperson it should pick up the 1st sales date ever and not just the 1st sales date for that salesperson. In this case Tom made the 1st sale  on 8/4/2008 and that should be Jerry's First Sales Date too. I tried this formula but it doesn't work 

 

VAR
FirstSalesDateKey =
CALCULATE(
MIN('Sales'[sales_date_key])
,ALLSELECTED('Sales'[customer_key])
,ALLEXCEPT('Salesperson','Salesperson'[Salesperson ID])
)

RETURN
IF(
FirstSalesDateKey = BLANK()
,-1
,FirstSalesDateKey
) 
Untitled.png

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below picture and the sample pbix file's link down below.

I tried to create a sample pbix file based on your explanation.

All measures are in the sample pbix file.

 

Picture1.png

First Sales Date fix =
IF (
ISFILTERED ( Customers[Customer] ),
IF (
NOT ISBLANK ( [Sales Total] ),
CALCULATE ( MIN ( Sales[Date] ), ALLEXCEPT ( Sales, Customers[Customer] ) )
)
)
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below picture and the sample pbix file's link down below.

I tried to create a sample pbix file based on your explanation.

All measures are in the sample pbix file.

 

Picture1.png

First Sales Date fix =
IF (
ISFILTERED ( Customers[Customer] ),
IF (
NOT ISBLANK ( [Sales Total] ),
CALCULATE ( MIN ( Sales[Date] ), ALLEXCEPT ( Sales, Customers[Customer] ) )
)
)
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Anonymous
Not applicable

Thank you @Jihwan_Kim it worked!!

Greg_Deckler
Super User
Super User

@Anonymous The problem is your ALLEXCEPT, this is preserving the Sales Person filter. Try replacing ALLEXCEPT with ALL


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler thanks for helping out. I I replaced the ALLEXCEPT with ALL but it didn't work

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.

Top Solution Authors