Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
HI everyone,
I have the following sample dataset, which contains customer ids and the year they have registered for an event, along with their registrationID, which is unique. The values in the Year column range between 2020 and 2024.
customerid || year || registrationid
LM-0001 || 2020 || ABC
LM-0002 || 2021 || ABCD
LM-0001 || 2021 || ABCDE
LM-0003 || 2022 || ABCDEF
LM-0002 || 2024 || ABCDEFG
What i want to achieve, is adding a calculated column which states whether they are a new customer or returning. One caveat is that the year 2020, all customers who registered, would have been "New Customers", as it was the first year, however if they then registered in 2023, they then would be classed as a returning customer.
The outcome would be to achieve the following table:
customerid || Year || registrationID || customerStatus
LM-0001 || 2020 || ABC || New
LM-0002 || 2021 || ABCD || New
LM-0001 || 2021 || ABCDE || Returning
LM-0003 || 2022 || ABCDEF || New
LM-0002 || 2024 || ABCDEFG || Returning
customer LM-0001 is a new customer being a registrant in 2020 however then returned in 2021, so they are deemed a returning customer. With LM-0002, they were a new customer in 2021 however they registered again in 2024, thus being a returning customer.
if a customer registered in 2022 and have not registered since, they would be listed as a new customer until they register again, in which their status for that relative year will be Returning.
I hope that makes sense, any help and guidance will be much appreciated.
Kind regards,
Calvin
Solved! Go to Solution.
Hello @TheMilkman,
Can you please try this:
customerStatus =
IF(
COUNTROWS(
FILTER(
ALL(Table),
Table[customerid] = EARLIER(Table[customerid]) && Table[year] < EARLIER(Table[year])
)
) > 0,
"Returning",
"New"
)
Should you require my further assistance, please do not hesitate to reach out to me.
hi, @TheMilkman
Try below code
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly. Appreciate your kudos
hi, @TheMilkman
Try below code
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly. Appreciate your kudos
Hello @TheMilkman,
Can you please try this:
customerStatus =
IF(
COUNTROWS(
FILTER(
ALL(Table),
Table[customerid] = EARLIER(Table[customerid]) && Table[year] < EARLIER(Table[year])
)
) > 0,
"Returning",
"New"
)
Should you require my further assistance, please do not hesitate to reach out to me.
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
12 | |
10 | |
6 |