Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Calculate Active Customers

Hello, Thanks in advance for your assistance. 

 

The following DAX lists the number of Active customers during a given month. My Years range over 2021, 2022 and will go into 2023. I don't want to show numbers for future dates. As we move into 2023, I don't want it to show monthly numbers for future Months. When I filter out the Month, it doesn't show any data for Dec of 2021.

 

How do I show the EndDatePerVisual to show MAX('Calendar'[Date]) as the last day of the month for all prior months but show Today() for the current Month & Year. 

 

Number of Active Customers =

var EndDatePerVisual = MAX('Calendar'[Date])

var ActiveCustomers =

CALCULATE(

    [Measure Count of New Customers],

    REMOVEFILTERS('Calendar'),

    'CustomerAccounts[Created Date] <=EndDatePerVisual,

    'CustomerAccounts'[Account Closure Date] > EndDatePerVisual

    || ISBLANK('CustomerAccounts'[Account Closure Date])

)

VAR Result =

If(

    Month(EndDatePerVisual) <= Month(TODAY()),

    ActiveCustomers

)

Return

Result

 

 

3 Replies