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
Anonymous
Not applicable

Count Months Since Inception with Filters

I'm trying to chart the annual return for several investments over a period of time. One of these time periods is "since inception", or since the first point of data for that investment. I also need to be able to filter the chart by investment, and by date to zoom in on a period. I'm trying to create a measure with the number of months since inception.

 

If I use something like

 

CALCULATE (
DISTINCTCOUNT('Returns'[Return Date]),
FILTER(ALL(Returns),
Returns[Return Date] <= MAX(Returns[Return Date])
)
)

then it calculates the number of months since the absolute first investment in any categories, ignoring all filters. If I change the code to use ALLSELECTED, it works until you try to filter by dates, at which point it just shows months since the earliest filtered date.

 

Is there a way that I can ignore the date filter in the calculations, but take into account the investment filter?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you! Not exactly what I needed, but put me on the right track - I didn't realise you could specify columns in ALL(). Searching for ALLEXCEPT led me to https://msdn.microsoft.com/en-us/library/ee634795.aspx which has a breakdown of when to use which function.

 

Now I'm using this - I had to add a date dimension table or the MAX comparison didn't work.

CALCULATE (
    DISTINCTCOUNT('Returns'[Return Date]),
    FILTER(ALL('Calendar'[Date]),
        'Calendar'[Date] <= MAX(Returns[Return Date])
)
)

View solution in original post

2 REPLIES 2
DAX0110
Resolver V
Resolver V

Have you tried the ALLEXCEPT filter?

Anonymous
Not applicable

Thank you! Not exactly what I needed, but put me on the right track - I didn't realise you could specify columns in ALL(). Searching for ALLEXCEPT led me to https://msdn.microsoft.com/en-us/library/ee634795.aspx which has a breakdown of when to use which function.

 

Now I'm using this - I had to add a date dimension table or the MAX comparison didn't work.

CALCULATE (
    DISTINCTCOUNT('Returns'[Return Date]),
    FILTER(ALL('Calendar'[Date]),
        'Calendar'[Date] <= MAX(Returns[Return Date])
)
)

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.