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

Filter by first x days per group

My question is, is there a way to get the first/earliest date per grouping in a table and then filter the table to only include rows within the first x number of months of that first date, per grouping. Probably easiest to ask with example. Say I have the following table, and want to keep data for first 6 months of each Group:

 

1.png

 

The resulting table would look like:

 

2.png

 

Is there a way to do this using DAX/M?

1 ACCEPTED SOLUTION
LivioLanzo
Solution Sage
Solution Sage

Hello @Anonymous

 

try like this:

 

FILTER(
    'Table',
    EDATE( [Date], -6 ) <=   CALCULATE( MIN( 'Table'[Date] ), ALLEXCEPT( 'Table', 'Table'[Group] ) )
)

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

View solution in original post

3 REPLIES 3
LivioLanzo
Solution Sage
Solution Sage

Hello @Anonymous

 

try like this:

 

FILTER(
    'Table',
    EDATE( [Date], -6 ) <=   CALCULATE( MIN( 'Table'[Date] ), ALLEXCEPT( 'Table', 'Table'[Group] ) )
)

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Anonymous
Not applicable

@LivioLanzothanks for your response. Where would I actually enter this code? Can you possibly provide PBIX file example?

@Anonymous

 

It is a DAX query which returns a table so you'd go to the 'Modeling' tab and click on 'New Table'

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

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.