Code Explainer | DAX

New Customer Acquisition

Calculate the number of new customers acquired in the current month by counting the customers present in 'AllCustomersPerMonth' but not in 'PreviousCustomers'.


Empty image or helper icon

This Query related with thread ""

Prompt

NewCustomers = 
        COUNTX(
            EXCEPT( AllCustomersPerMonth[Customers],  PreviousCustomers[Customers]), 
            [Customers]
        )

Answer

Sure, let's break down the code snippet you provided.

NewCustomers = 
    COUNTX(
        EXCEPT(AllCustomersPerMonth[Customers], PreviousCustomers[Customers]), 
        [Customers]
    )

DAX Functions Used:

There are two main DAX (Data Analysis Expressions) functions used:

  1. COUNTX: A DAX statistical function that counts the number of rows of data in a column, where the values in each row are evaluated by their expression or measure.

  2. EXCEPT: A DAX function that returns the rows of a table that are present in the first table parameter and not present in the second table parameter.

Explanation:

The overall aim of this code is to calculate the number of new customers, i.e., customers that are in 'AllCustomersPerMonth' but not in 'PreviousCustomers'.

  1. EXCEPT(AllCustomersPerMonth[Customers], PreviousCustomers[Customers]):

    This part is using the EXCEPT function to find out the customers that are present in 'AllCustomersPerMonth' but not present in 'PreviousCustomers'. So basically, it's isolating the "new" customers.

  2. COUNTX([...], [Customers]):

    The COUNTX function then counts the number of these new customers. It goes through the result of the EXCEPT function (a table of new customers) and counts the number of unique [Customers].

Conclusion:

The variable NewCustomers will thus hold the count of new customers that haven't made purchases in previous months but did in the current month. This type of calculation is valuable in business analyses for understanding customer growth and acquisition.

Also for further knowledge on DAX formulas and how to use them, Enterprise DNA Platform offers several in-depth courses which you may find beneficial. These courses provide a comprehensive understanding of how DAX functions work and how they can be applied to solve complex problems.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

The given code snippet calculates the number of new customers acquired in the current month. It utilizes DAX functions to isolate the customers present in 'AllCustomersPerMonth' but not in 'PreviousCustomers'. The 'EXCEPT' function is used to find the new customers, and then the 'COUNTX' function counts the number of these new customers. This calculation is useful for tracking customer growth and acquisition in business analyses. For a deeper understanding of DAX functions and their application, the Enterprise DNA Platform offers comprehensive courses on DAX formulas.