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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Charles59
New Member

DAX: How to count customers who buys the month of april only and not the others.

Hi everyone, 

I have an issue on DAX that I can't solve, maybe someone could help. 

Here is my example

My problem: I would like to count the number of new customers who bought in April ONLY and not during previous months. 

In our case, 2 new customers (customer C & D)

Let's imagine a purchase teble like below: 

CustomerMonth of purchase
A1
A2
A4
B1
B3
C4
C4
D4
1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

Apr ONLY = 
CONCATENATEX(
    FILTER(
        CALCULATETABLE( VALUES( SALES[Customer] ), SALES[Month of purchase] = 4 ),
        CALCULATE( ISEMPTY( SALES ), SALES[Month of purchase] <> 4 )
    ),
    SALES[Customer],
    ", "
)

ThxAlot_0-1691180068161.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

2 REPLIES 2
ThxAlot
Super User
Super User

Apr ONLY = 
CONCATENATEX(
    FILTER(
        CALCULATETABLE( VALUES( SALES[Customer] ), SALES[Month of purchase] = 4 ),
        CALCULATE( ISEMPTY( SALES ), SALES[Month of purchase] <> 4 )
    ),
    SALES[Customer],
    ", "
)

ThxAlot_0-1691180068161.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



HassanAshas
Helper V
Helper V

Please try the following, 

Count of People = 

var _OtherCustomers = 
    CALCULATETABLE(
        VALUES('Table'[Customer]), 
        'Table'[Month of purchase] < 4
    )

var _Result =
    COUNTROWS(
        SUMMARIZE(
            FILTER(
                'Table', 
                'Table'[Month of purchase] = 4
                &&
                NOT('Table'[Customer] in _OtherCustomers)
            ), 
            'Table'[Customer]
        )
    )

return _Result

 

The idea is to, 

 

  • Find out the Customers who have purchases in the Months less than "4"
  • Filter the Table to only find the people who have done purchases in the Month = 4 and also filter out those Customers in this table who belong to the first list (_OtherCustomers as caluclated above)
  • Summarize this resultant table based upon Customer (so as to find unique number of Customers)
  • Finally count the Rows in the summarized table. This should give you your final answer. 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.