Forum Discussion

AlB's avatar
AlB
Community Champion
5 years ago
Solved

Optimizing measure - Segment migration

Hi all, See the attached file for support. We have a simple one-table model: CustomerId Dates Segment 6 03/01/2020 Segment2 7 03/01/2020 Segment2 6 03/02/2...
  • mwegener's avatar
    5 years ago

     

    Hi AlB ,

     

    try this.

    Net new customers v2 = 
    VAR _CurrentDate =
        SELECTEDVALUE (Table1[Dates] )
    VAR _PreviousDate =
        CALCULATE (
            MAX ( Table1[Dates] ),
            ALLSELECTED ( Table1[Dates] ),
            Table1[Dates] < _CurrentDate
        )
    VAR _CountCustomerIDsThisMonth =
        CALCULATE( 
            DISTINCTCOUNT(Table1[CustomerId]),
            Table1[Dates] = _PreviousDate ||
            Table1[Dates] = _CurrentDate
        )
    VAR _CountCustomerIDsPreviousMonth =
        CALCULATE( 
            DISTINCTCOUNT(Table1[CustomerId]),
            Table1[Dates] = _PreviousDate
        )
    RETURN
        _CountCustomerIDsThisMonth - _CountCustomerIDsPreviousMonth