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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Shineccx007
Helper I
Helper I

Count new customer for current year

Hi,

 

Under value entries we are able to calculate all the historical sales revenue.

 

Now I wanted to count the new customers this year.

 

The new customer logic should be [Current year sales] = [Total sales] and I wanted to distinct count the Customer ID. But countrows will count every transaction lines that show on Value Entries.

 

Anybody got any suggestion?

 

I also tried distinct count, but the DAX showed error.

1 ACCEPTED SOLUTION
v-junyant-msft
Community Support
Community Support

Hi @Shineccx007 ,

Here is my sample data:

vjunyantmsft_0-1721719830418.png

First use this DAX to create a calculated column:

Flag = 
VAR CurrentYear = YEAR(TODAY())
VAR _Total = 
CALCULATE(
    SUM('Table'[Sales]),
    ALLEXCEPT('Table', 'Table'[Customer ID])
)
VAR _Current =
CALCULATE(
    SUM('Table'[Sales]),
    ALLEXCEPT('Table', 'Table'[Customer ID]),
    YEAR('Table'[Date]) = CurrentYear
)
RETURN
_Total - _Current

vjunyantmsft_1-1721719877085.png

Then use this DAX to create a measure:

Count = 
CALCULATE(
    DISTINCTCOUNT('Table'[Customer ID]),
    'Table'[Flag] = 0
)

The final output is as below:

vjunyantmsft_2-1721719935431.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-junyant-msft
Community Support
Community Support

Hi @Shineccx007 ,

Here is my sample data:

vjunyantmsft_0-1721719830418.png

First use this DAX to create a calculated column:

Flag = 
VAR CurrentYear = YEAR(TODAY())
VAR _Total = 
CALCULATE(
    SUM('Table'[Sales]),
    ALLEXCEPT('Table', 'Table'[Customer ID])
)
VAR _Current =
CALCULATE(
    SUM('Table'[Sales]),
    ALLEXCEPT('Table', 'Table'[Customer ID]),
    YEAR('Table'[Date]) = CurrentYear
)
RETURN
_Total - _Current

vjunyantmsft_1-1721719877085.png

Then use this DAX to create a measure:

Count = 
CALCULATE(
    DISTINCTCOUNT('Table'[Customer ID]),
    'Table'[Flag] = 0
)

The final output is as below:

vjunyantmsft_2-1721719935431.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PhilipTreacy
Super User
Super User

Hi @Shineccx007 

 

Please check this : How to get your question answered

 

regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.