Forum Discussion

asd2525's avatar
asd2525
Regular Visitor
6 years ago
Solved

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. 

  • 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 )
    
    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.

3 Replies

  • AnkitBI's avatar
    AnkitBI
    Icon for Solution Sage rankSolution Sage
    Share Sample data for your table or a copy of your pbix file with data
    • asd2525's avatar
      asd2525
      Regular Visitor

      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
      • v-juanli-msft's avatar
        v-juanli-msft
        Icon for Community Support rankCommunity Support

        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 )
        
        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.