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
asd2525
Regular Visitor

PowerPivot CountIf date in one row is after a date in another

I am using Power Query and Power Pivot to try and create a living report that can be edited. I have one column with a unique ID, another with the date the entry was made, and another with the follow up date. I want to write a formula that essentially is a countif funtion. I want it to count the number of rows that match the ID of that row and have an entry date equal to or greater than the follow up date. I have tried numerous formulas with Calculate and Countrows but I can't figure out how to get this to come out. Any help would be appreciated. 

1 ACCEPTED SOLUTION

Hi @asd2525 

Create a new column

new column =
VAR Max_each_id =
    CALCULATE ( MAX ( 'Table'[Entry Date] ), ALLEXCEPT ( 'Table', 'Table'[ID] ) )
RETURN
    IF ( Max_each_id >= [Followup Date], 1, 0 )
Capture20.JPG
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
AnkitBI
Solution Sage
Solution Sage

Share Sample data for your table or a copy of your pbix file with data

I am dealing with HIPPA data so I can't share but this is an example of what I want to be able to do with powerpivot.

The equation that I would use in a regular table would be =IF(COUNTIFS($D$2:$D$5,$D2,$A$2:$A$5,">="&$E2),"Yes","No")

I can't figure out how to get the same results with PowerPivot

DateName DOBIDFollowup DateFollowup Occurred?
8/18/2019John Doe1/1/1901John Doe3679/18/2019Yes
8/25/2019Jane Doe2/2/1902Jane Doe7649/25/2019No
9/3/2019John Smith3/3/1903John Smith115810/3/2019No
9/18/2019John Doe1/1/1901John Doe36710/18/2019No

Hi @asd2525 

Create a new column

new column =
VAR Max_each_id =
    CALCULATE ( MAX ( 'Table'[Entry Date] ), ALLEXCEPT ( 'Table', 'Table'[ID] ) )
RETURN
    IF ( Max_each_id >= [Followup Date], 1, 0 )
Capture20.JPG
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

Top Solution Authors
Top Kudoed Authors