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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
mabCOLONEL
Frequent Visitor

Count dates past a dynamic date on another table with criteria.

Hi everyone.  I have a pretty basic need for a measure here.  I have two tables.  One has an index of location attributes.  It includes an 'end date'.  Another table is production data.  So actions that get completed for each location and the date of those actions.  I use a matrix to display the location, and the number of times certain actions took place in a certain date rage.  I would also like to add a column for a count of actions that took place after the 'end date' listed for that location.  Below is a mock up of what I am trying to accomplish.  In excel I would do a countif(date@row,=index(match end date)...not correct i know, but you get the point i think.  Thanks in advance for the help!
Screenshot 2023-01-12 092955.png

1 ACCEPTED SOLUTION

I made a measure for the 'end date' (End Date = 'Index'[End Date] and just added that to countrows measure:

past end date = COUNTROWS(FILTER('Data Points','Data Points[Date] > 'Index'[End Date]))

View solution in original post

3 REPLIES 3
Barthel
Solution Sage
Solution Sage

Hey @mabCOLONEL,

You can create a measure for this that you can place in a matrix. This measure calculates per location the number of rows (actions) whose date is after the end date. And then takes the sum of that.

Past End = 
SUMX (
    KEEPFILTERS ( 'Index' ),
    CALCULATE (
        COUNTROWS ( 'Data Points' ),
        'Data Points'[Date] > EARLIER ( 'Index'[End Date] )
    )
)

I made a measure for the 'end date' (End Date = 'Index'[End Date] and just added that to countrows measure:

past end date = COUNTROWS(FILTER('Data Points','Data Points[Date] > 'Index'[End Date]))

Hi @Barthel ,

I used that measure but did not get the anticipated result.  I am not sure why these rows from my data are geting a value.  You can see the 'end date' is clearly after the 'latest note' (action date) but the measure is still couting it as one. 
Screenshot 2023-01-12 114133.png

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.