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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
RAQuest
New Member

Find the number of unique customer over a two year period

Hello - I am trying to solve how to find the number of unique customer different regions acquire of a year period. The solution will help my sales leadership see how many new customers are buying from us this year vs last year. We do have repeat customers and when I use "distinctcount" and drop in the year repeat customers get counted in each year.

 

In the image below, the two rows in yellow indicate where the same customer purchased in 2023 and 2024, but should of only been counted in 2023.

 

Can anyone help?

 

RAQuest_0-1712708800733.png

 

1 ACCEPTED SOLUTION

Hi @RAQuest ,

Try replacing SELECTEDVALUE with MIN.

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

5 REPLIES 5
v-cgao-msft
Community Support
Community Support

Hi @RAQuest ,

Please try this measure:

Measure = 
VAR __cur_year = SELECTEDVALUE('Date'[Year])
VAR __pre_year_count = CALCULATE(DISTINCTCOUNT('Table'[Customer Name]),'Date'[Year]=__cur_year-1)
VAR __cur_year_count = DISTINCTCOUNT('Table'[Customer Name])
VAR __result = IF(ISBLANK(__cur_year_count) || __pre_year_count>0, BLANK(), 1)
RETURN
__result

vcgaomsft_0-1712813845435.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Gao,

 

Thank you for the response - I am trying to create this measure in Power Pivot and not PBI. I noticed in your solution "SelectedValue" is not an option in Power Pivot. How would you suggest around this issue?

 

Thanks in advance for your time,

 

RA

Hi @RAQuest ,

Try replacing SELECTEDVALUE with MIN.

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Gao - thank you - this worked and I appreciate the help. If you could help me with one final tweek, I would appreciate it. I am showing the number of accounts (thank you), but I do not show a total - see image and measure below.

 

YoY Customer Count:=VAR CurrentYear = YEAR(TODAY())

VAR PreviousYearCount = CALCULATE(DISTINCTCOUNT('Table2'[BillToName]),'Calendar'[Year]=CurrentYear-1)

VAR CurrentYearCount = DISTINCTCOUNT('Table2'[BillToName])

VAR Result = IF(ISBLANK(CurrentYearCount) || PreviousYearCount>0, BLANK(), 1)

RETURN

Result

 

RAQuest_0-1714329514192.png

 

Greg_Deckler
Super User
Super User

@RAQuest Is that what the source data looks like or ? Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, 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

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



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
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors