Forum Discussion

wongts_nms's avatar
wongts_nms
New Member
1 year ago
Solved

Match 2 Tables using Measure (with conditions)

Hi, Expert,   I wish to create a measure in the Power BI to match the following condition but unable to get the correct matching: I have 2 tables:  Bank and GL In the bank table, there is a dep...
  • BeaBF's avatar
    BeaBF
    1 year ago

    wongts_nms try with:

     

    IsBankMatched =
    VAR SelectedBankIn = SELECTEDVALUE(Bank[In])
    VAR GLTotal =
    CALCULATE(
    SUM(GL[Debit]),
    FILTER(
    GL,
    GL[Clean Ref Numeric] = SelectedBankIn
    )
    )
    RETURN
    IF(
    NOT ISBLANK(SelectedBankIn)
    && ABS(GLTotal - SelectedBankIn) < 0.01,
    "Matched",
    "Not Matched"
    )

     

    BBF


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

    👍 Kudos are appreciated

    🔥 Proud to be a Super User!

  • sevenhills's avatar
    1 year ago

    Try and see if this works:

    IsBankMatched =
    VAR _BankIn = SELECTEDVALUE(Bank[In])
    VAR _Date = SELECTEDVALUE(Bank[Date])
    
    VAR GLTotal = CALCULATE( SUM(GL[Debit]),
                     FILTER( ALL(GL), GL[Clean Ref Numeric] = _BankIn && GL[Date] = _Date)
                  )
    -- RETURN IF( NOT ISBLANK(_BankIn) && NOT ISBLANK(_Date) && ABS(GLTotal - _BankIn) < 0.01,
    -- RETURN IF ( HASONEVALUE ( Bank[In]) && HASONEVALUE(Bank[Date]) && ABS(GLTotal - _BankIn) < 0.01,
    RETURN IF(   ABS(GLTotal - _BankIn) < 0.01,
                "Matched", "Not Matched"
           )

     

    ALL(GL) or ALLSELECTED(GL) based on your needs, if the above formula works!