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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
clo_64
Frequent Visitor

Sum multiple results from COUNTROWS

Hi,

I would like to count all the New Customers for the actual year (= YTD).

 

My measure works very well when I use it and build a table with the date 'Date'[Date]

 

But how can I sum all the COUNTROWS to get the number of customers since Jan 2022.

Here the measure I use to get the New Customer / month. How can I change this with SUMX? to get a sum for 2022?

New Customers YTD =
VAR currentCustomers = VALUES('SalesReport'[Customer])
VAR currentDate = MIN('Date'[Date])
VAR Period = 'Period in months'[Period in months Value]*30
VAR pastCustomers = CALCULATETABLE(VALUES('SalesReport'[Customer]),
ALL('Date'[Date]),
'Date'[Date]<currentDate && 'Date'[Date] + Period >currentDate)

VAR newCustomers = EXCEPT(currentCustomers,pastCustomers)

RETURN COUNTROWS(newCustomers)

Thanks

6 REPLIES 6
Anonymous
Not applicable

Hi @clo_64 ,

 

Try:

measure =
SUMX (
    FILTER ( ALLSELECTED ( 'date' ), 'date'[date] >= DATE ( 2022, 1, 1 ) ),
    [New Customers YTD]
)

If I misunderstood your meaning, please share some sample data.

 

Best Regards,

Jay

Hi Jay,
The result that I get is not correct! The measure gives me 44K, and I expect around 400.
I'll try to debug in DAXstudio and share my findings later
Thanks

speedramps
Super User
Super User

Sorry I am a unpaid volunteer and busy until next week.

Hope another Super User can help in the meantime.

Otherwise I will fix it next week

fine! I understand...
Next week is OK

speedramps
Super User
Super User

Try this 

 


Total New Customers =
/* DOCUMENTATION
Get number of new customers as follows:-
Use addcolumns to get a set with (Customer,Previous Rows)
Then filter the set to just to include Customers with no previous rows.
Then count the number of Customers
*/

VAR mindate = DATE(2022,01,01)

VAR NewCustomers =
FILTER (
ADDCOLUMNS (
VALUES ( 'SalesReport'[Customer] ),
"PreviousRows",
CALCULATE (COUNTROWS ('SalesReport'),
FILTER (ALL ( 'Date'[Date]),'Date'[Date]< mindate))
),
[PreviousRows] = 0
)

RETURN
COUNTROWS(NewCustomers)

 

 

 

Then drag  [Total New Customers] yo a card visual with no filters

 

Thanks for reaching out for help.

I have helped you, now please help me by giving kudos.

Remeber we are unpaid volunteers.

Click the thumbs up and accept as solution button. 

One question per ticket please. If you need to extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you !

Thanks this is going in the right direction, but not exactly what I was looking for.
Here you are calculating the New Customers by comparing the customers in 2022 with the customers in 2021.
In my measure, I defined a new customer as someone I did not see for a certain rolling period:
'Date'[Date]<currentDate && 'Date'[Date] + Period >currentDate
and then I want to sum up all the new customers in 2022.
Thanks in advance

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors