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

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors