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
josimarjr
New Member

New customers per service unit

I need to create a measure to identify new customers by service unit.

I made the measurement below, but in some cases the customer returns as new, but the customer has already bought it at another store in the group.

I need that when filtering the store, it is checked if the customer has already purchased from another store in the group. If the customer has a purchase in another store of the same group, do not consider it as new.

Filters used for return:
- Date of Purchase
- Service Unit

 

Qty_New_Customers =
COUNTROWS(
FILTER(
ADDCOLUMNS(VALUES(PURCHASES[Customer Code]),
"New clients",
CALCULATE(COUNTROWS(PURCHASE),FILTER(ALL(PURCHASE_DATE),PURCHASE_DATE[Purchase_Date]<MIN(PURCHASE_DATE[Purchase_Date])))),
[New Customers] = 0))

 

Ex: When filtering the month of April/2023 and unit B, the measure returns customer 1002732 as new (First Purchase), but in fact the customer had already purchased from another unit in the group in February/2023.

 

Customer_CodePurchase_CodePurchase_DateService_Unit
10027323262010407/02/2023Unit A
10027323262010408/02/2023Unit A
10027323262010410/04/2023Unit B

 

Thank you very much.




5 REPLIES 5
v-cgao-msft
Community Support
Community Support

Hi @josimarjr ,

Please create a new measure.

New_Customers_Number = 
VAR _mindate =
    CALCULATE (
        MIN ( 'PURCHASE_DATE'[Purchase_Date] ),
        ALL ( 'PURCHASE'[Service_Unit] )
    )
VAR _table_1 =
    CALCULATETABLE (
        VALUES ( 'PURCHASE'[Customer_Code] ),
        FILTER ( ALL ( 'PURCHASE_DATE' ), 'PURCHASE_DATE'[Purchase_Date] < _mindate )
    )
VAR _table_2 =
    CALCULATETABLE ( VALUES ( 'PURCHASE'[Customer_Code] ), ALLSELECTED () )
VAR _result =
    COUNTROWS ( EXCEPT ( _table_2, _table_1 ) ) + 0
RETURN
    _result

vcgaomsft_0-1683167934352.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Hello,

 

Thank you very much for his input, but it still didn't work out.

Using your example to meet my need, the customer should be considered as new on 07/02/2023 (date of first purchase).

I think there's just one small detail missing.

 

Customer_CodePurchase_DateService_UnitNew_Customers_Number
100273207/02/2023 00:00Unit A1
100273208/02/2023 00:00Unit A0
100273315/04/2023 00:00Unit A1

 

Thank you very much

josimarjr
New Member

Hello,

 

all mentioned columns are in the same table or have relationship.

Hello,

 

Try this once!

 

4444.JPG

Wilson_
Memorable Member
Memorable Member

Hello,

 

Hard to know for sure this will work since you've shared nothing about your data model (that cannot be inferred from your measure), but what if you add a second filter parameter "REMOVEFILTERS ( Service_Unit )" to your "New Clients" CALCULATE function?

 

If that doesn't work, please share a pbix.


----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)

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.

Top Solution Authors