Forum Discussion

Mkrishna's avatar
Mkrishna
Icon for Helper III rankHelper III
2 years ago

Number of New Customer Using Except

Hi All,

I am trying to find the number of New Customer using Except function. The dax codes give correct total but when I put the context Territory Manager  in the table view, the number of customer for each of most of the sales rep is correct but in case of some TM, some new store number are added but the total is still correct.

I have a date slicer which is month and year only. When the user select March in the slicer, the code will compute the numbe rof customer from Jan and Feb in one variable . In another variable it  ill compute the store number in March 2023(selected slicer value). The it will out the store that are present in March but not in Jan and Feb. Thsi is what i intend to do. 

In my code, the total is correct, but the when I put theTM in context, the total is still correct but the some of theTM now has higer new customers than it should have been.

 

 

Nos. of New Customers =

 

VAR StartDate = DATE(2023, 01, 01)

VAR PreviosEndDate = EOMONTH(MAX('Dates'[Date]), -1)

 

VAR DistinctStoreTillPreviousEndDate = CALCULATETABLE(

    DISTINCT('Store’ [Store Number]), DATESBETWEEN(Dates[Date], StartDate,PreviosEndDate)

    )

 

VAR DistinctStoreTillCurrentEndDate = CALCULATETABLE(

     DISTINCT(‘Store’[Store Number]))

   

var x =

    COUNTROWS(

        EXCEPT(DistinctStoreTillCurrentEndDate, DistinctStoreTillPreviousEndDate)

    )

return x

My data mode is 

 

2 Replies