Forum Discussion

MojoGene's avatar
MojoGene
Post Patron
10 years ago
Solved

Logical comparison between different columns?

The data in my PBI model are from a SQL database for Time & Billing in a professional services firm. I am attempting to create a report on "leverage," which is the sum of hours worked on a matter by ...
  • v-ljerr-msft's avatar
    10 years ago

    MojoGene

     


    My initial thinking was a measure like this:

    = CALCULATE(SUM(Fact[Hours]),Fact[TimekeeperID]<>Matter[OriginatingTimekeeperID])

    But alas, I got the error message: "The expression contains multiple columns, but only a single column can be used in a True/False expression that is used as a table filter expression."

     

    Is there a way to perform a logical comparison (true/false) on different columns in different tables?


     

    If you need to invoke CALCULATE using more than one column in the condition, you need to use FILTER function, which provides a list of values instead of a condition. Since these two tables are related by the "Matter Number" field, you can use RELATED() function to compare two column values.

     

    Please refer to formula below:

    =
    CALCULATE (
        SUM ( Fact[Hours] ),
        FILTER (
            Fact,
            Fact[TimekeeperID] <> RELATED ( Matter[OriginatingTimekeeperID] )
        )
    )

     

    Regards,

    Jerry