Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Mikebuci99
New Member

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

 

Mikebuci99_0-1668727609713.png

 

3 REPLIES 3
daXtreme
Solution Sage
Solution Sage

Here is your problem:

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

The comparison makes sure that year is not taken into account, only the month. You should check not only the month but the year as well. Even better, you should have a column in your date table that marks days as "past", "today", "future." Then it's easy to filter for past+today in any of your measures or via slicers.

Thanks for the response. I will look work on adding the recommended column to the date table. 

 

How would I add the Year and Month to this section though?

 

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

 

amitchandak
Super User
Super User

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.