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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
monojchakrab
Resolver III
Resolver III

Split sales by new & repeat customers

I have a table (attached herewith), which contains sales by customer by month.

I want to split the sales for every month, by customers who are new in that month and by returning customers.

I have seen a few video lessons on the internet, but none of them seem to solving the problem.

Basically, if a customer name, in a given month, has occured more than once, before the current month and has a non-blank sales value, then he is a returning customer, else he is a new customer for the month

So if I can generate a column which can flag off the customer name as "new" or "repeat" - that should solve the problem I guess

I have probably got the logic right but not able to dax it into a measure or a column.

Any help appreciated

DateCUSTOMER NAMEUnits sold
31-03-2022TUNGA PARADISE500
31-03-2022Ambassator Pallava500
31-03-2022Zone The Park500
31-03-2022Beverly500
31-03-2022Gokulam Park500
31-03-2022Holiday Express500
31-03-2022Raj Park500
31-03-2022Vestin Park500
31-03-2022Vijay Park500
31-03-2022Shelter500
31-03-2022Fairfield Marriott500
31-03-2022Fairfield Marriott500
31-03-2022MGM Healthcare500
31-03-2022Empire Agencies500
31-03-2022Ideal Beach500
31-03-2022Green Meadows500
31-03-2022Hot Chips500
31-03-2022Park Plaza500
31-03-2022Wellsell Foods500
31-03-2022Fortune Pandiyan500
31-03-2022Surya Chandra Enterprises500
31-03-2022RNVN Enterprises500
31-03-2022HOTEL TAZZ ODISHA500
30-04-2022Ambassator Pallava500
30-04-2022Beverly500
30-04-2022Gokulam Park500
30-04-2022Holiday Express500
30-04-2022Raj Park500
30-04-2022Vijay Park500
30-04-2022Shelter500
30-04-2022Fairfield Marriott500
30-04-2022Ideal Beach500
30-04-2022Poppy`s Tower500
30-04-2022Sterling500
30-04-2022GREENWOODS HOSPITALITY PVT LTD500
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

It is for creating a calculated column.

You can add some more logics into the Calculated Column, if it is needed.

 

Untitled.png

 

Flag CC =
VAR _currentcustomer = Data[CUSTOMER NAME]
VAR _lastdateofpreviousmonth =
    EOMONTH ( Data[Date], -1 )
VAR _previousmonthtablecurrentcustomer =
    FILTER (
        Data,
        Data[CUSTOMER NAME] = _currentcustomer
            && Data[Date] <= _lastdateofpreviousmonth
            && Data[Units sold] <> BLANK ()
    )
RETURN
    IF ( COUNTROWS ( _previousmonthtablecurrentcustomer ) >= 1, "Repeat", "New" )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
monojchakrab
Resolver III
Resolver III

I will try this out @Jihwan_Kim - but from the look of it, this should work.

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

It is for creating a calculated column.

You can add some more logics into the Calculated Column, if it is needed.

 

Untitled.png

 

Flag CC =
VAR _currentcustomer = Data[CUSTOMER NAME]
VAR _lastdateofpreviousmonth =
    EOMONTH ( Data[Date], -1 )
VAR _previousmonthtablecurrentcustomer =
    FILTER (
        Data,
        Data[CUSTOMER NAME] = _currentcustomer
            && Data[Date] <= _lastdateofpreviousmonth
            && Data[Units sold] <> BLANK ()
    )
RETURN
    IF ( COUNTROWS ( _previousmonthtablecurrentcustomer ) >= 1, "Repeat", "New" )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.