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

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
)

1 ACCEPTED SOLUTION
Community Champion

Hi, @lefli

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.

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 accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

4 REPLIES 4
Community Champion

Hi, @lefli

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.

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 accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

Frequent Visitor

Thank you @Jihwan_Kim it worked!!

Super User IV

@lefli 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!!!

I have a NEW book! DAX Cookbook from Packt
Over 120 DAX Recipes!

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Frequent Visitor

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

Helpful resources

Announcements

Manage your user group events

Check out the News & Announcements to learn more.

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Top Kudoed Authors