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
Anonymous
Not applicable

Identify new customers using date differences

I’m currently developing an arrears report based on the following table. I want to look at the new customers that went into arrears this week. So, I only want to include customer C this week (26/06/2023) because A and B was in arrears last week. How can I do this in a measure?

Customer

Date

A

26/06/2023

B

26/06/2023

C

26/06/2023

A

19/06/2023

B

19/06/2023

 

I’m thinking of a measure using Dateadd.

New customers in arrears=

Var CurrentDate = selectedvalue (‘Table’[Date])

Return

Calculate(count(‘table’[Customer]), “check if each company has date = dateadd(CurrentDate, -7, Days)”)

2 REPLIES 2
Martin_D
Super User
Super User

Hi @Anonymous ,

From your sample data and description I assume the following constraints:

  • You only want to compare with the directly previous week, not with all previous weeks
  • You have weekly data, every 7 days, so you only need to compare with exactly 7 days earlier, not with all dates in the previous week

Then try the following:

 

Count of new customers = 
VAR _selectedWeek = MAX ( 'Table'[Date] )
VAR _previousWeek = _selectedWeek - 7
VAR _customersSelectedWeek =
    CALCULATETABLE (
        VALUES ( 'Table'[Customer] ),
        'Table'[Date] = _selectedWeek
    )
VAR _customersPreviousWeek =
    CALCULATETABLE (
        VALUES ( 'Table'[Customer] ),
        'Table'[Date] =_previousWeek
    )
VAR _newCustomers = EXCEPT ( _customersSelectedWeek, _customersPreviousWeek )
VAR _countOfNewCustomers = COUNTAX ( _newCustomers, [Customer] )
RETURN
_countOfNewCustomers

 

 

github.pnglinkedin.png

Anonymous
Not applicable

This works great. Thank you @Martin_D 

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.