Search code examples
powerbidaxmeasure

New Customer measure


Good day!

I have this measure which used to identify which clients are new based on the parameter (6 month) and also month & year of their ETD.

New Customers = //Cus
VAR CustomerTM = VALUES(Customer[Client])
VAR PriorCustomer = CALCULATETABLE(VALUES(Customer[Client]),
FILTER(ALL('Customer'),
'Customer'[ETD] > Min('Customer'[ETD] ) - Parameter[Parameter Value] && 'Customer'[ETD] < MIN('Customer'[ETD])))
return
COUNTROWS(
EXCEPT(CustomerTM,PriorCustomer))

My raw data:

Raw Data

There are no problems with the coding until the 'branch' slicer is added.

Based on my raw data, Nike should consider new customers for SIN branch in January, but for TYO branch in February.

But this code as a result, NIKE only had new customers on January, is there any part that I was missed?

Slicer 'Jan' and Branch 'SIN'

Slicer 'Feb' and Branch 'TYO'

Attached with pbix: https://drive.google.com/file/d/1mvW9opym6Ot2AlyZy0m0kl2rDeB4P2Wv/view?usp=sharing

Greatly appreciated any helps provided! Thank you!


Solution

  • Try ALLEXCEPT() instesd of ALL in your FILTER. All() removes all filters and slicers from you data. Only Parameter[Parameter Value] infuences your FILTER. So if you do not change it in all other cases you have the same result.

       FILTER(
             ALLEXCEPT('Customer',Customer[Branch])
             ,AND(
                 'Customer'[ETD] > Min('Customer'[ETD] ) - Parameter[Parameter Value]
                 ,'Customer'[ETD] < MIN('Customer'[ETD])
             )
       )