Forum Discussion

Phil-osophy's avatar
Phil-osophy
Icon for Helper I rankHelper I
7 years ago
Solved

Transaction Matching

Hey everyone,   this post is follow up to my previous one as i have found some errors in the output. Credit Adjustment Column = - IF ( Sheet1[transaction type] = "credit adjustment", [amount], BL...
  • jdbuchanan71's avatar
    jdbuchanan71
    7 years ago

    Phil-osophy 

    I think this will do the trick for you.  It allows the match to only apply to the first purchase date that matches the amount.

    Credit adjustment match with equivalent purchase = 
    VAR ABC =
        CALCULATETABLE (
            VALUES ( Sheet1[Credit Adjustment Column] ),
            FILTER ( ALL ( Sheet1 ), Sheet1[Employee ID] = EARLIER ( Sheet1[Employee ID] ) ),
            Sheet1[Credit Adjustment Column]
        )
    VAR MatchDate = 
        CALCULATE(
            MIN(Sheet1[transaction date]),
            FILTER ( ALL(Sheet1), 
            Sheet1[Employee ID] = EARLIER ( Sheet1[Employee ID] ) &&
            Sheet1[transaction type] = "purchase" &&
            Sheet1[amount] = EARLIER(Sheet1[amount])
            ))
    
    RETURN
        IF ( [amount] IN ABC && [transaction date] = MatchDate, "matched", "nope" )