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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Syndicate_Admin
Administrator
Administrator

Help with calculating new customers based on their purchases only in the last month

Dear

I want to calculate the new customers who bought out of 1 in the last month and that the months before the current month are blank.

In excel I make the detailed formula in the image:

fórmula.jpg

The sum corresponds to all the months prior to the current one and if the current month is greater than 1.

Please if you can help me with a Dax for this one or some alternative to replicate this in PowerBi.

Thanks a lot

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Syndicate_Admin 

 

I have simulated some data that I hope fits your description.

Column = VAR n1 = 
CALCULATE (
    COUNT ( 'Table'[Customer] ),
    FILTER (
        'Table',
        [Purchase time].[MonthNo]
            = MONTH ( TODAY () ) - 1
            && [Customer] = EARLIER( ( 'Table'[Customer] )
    )
))  Var n2 =
CALCULATE (
    COUNT ( 'Table'[Customer] ),
    FILTER (
        'Table',
        [Purchase time].[MonthNo]
            <> MONTH ( TODAY () ) - 1
            && [Purchase time].[MonthNo] <> MONTH ( TODAY () )
            && [Customer] = EARLIER ( 'Table'[Customer] )
    )
)
Return IF(n1>=1&&n2=0,"New",BLANK())

vzhangti_0-1640584989897.png

If the method I provided above can't solve your problem, what's your expected result? Could you please provide more details for it?

 

Best Regards,

Community Support Team _Charlotte

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

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Share some data, describe the question and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Syndicate_Admin
Administrator
Administrator

thank you very much for the help, but I have a doubt.

&& [Customer] = EARLIER( ( 'Table'[Customer] )

In that part my custumer table has to be a measure? I can't add only the greetings field

Hi, @Syndicate_Admin 

 

Can you provide easy PBIX files for testing? I would like to know the format of custumer table. Looking forward to your reply.

 

Best Regards,

Community Support Team _Charlotte

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

 

v-zhangti
Community Support
Community Support

Hi, @Syndicate_Admin 

 

I have simulated some data that I hope fits your description.

Column = VAR n1 = 
CALCULATE (
    COUNT ( 'Table'[Customer] ),
    FILTER (
        'Table',
        [Purchase time].[MonthNo]
            = MONTH ( TODAY () ) - 1
            && [Customer] = EARLIER( ( 'Table'[Customer] )
    )
))  Var n2 =
CALCULATE (
    COUNT ( 'Table'[Customer] ),
    FILTER (
        'Table',
        [Purchase time].[MonthNo]
            <> MONTH ( TODAY () ) - 1
            && [Purchase time].[MonthNo] <> MONTH ( TODAY () )
            && [Customer] = EARLIER ( 'Table'[Customer] )
    )
)
Return IF(n1>=1&&n2=0,"New",BLANK())

vzhangti_0-1640584989897.png

If the method I provided above can't solve your problem, what's your expected result? Could you please provide more details for it?

 

Best Regards,

Community Support Team _Charlotte

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

 

Greg_Deckler
Super User
Super User

@Syndicate_Admin See if this helps: New and Returning Customers - Microsoft Power BI Community


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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