Forum Discussion
Logical comparison between different columns?
- 10 years ago
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
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
- MojoGene10 years ago
Post Patron
Jerry:
That nailed it. I had been trying to wrap my mind around the RELATED function for the last day or so, but was finding this problem unusually challenging.
Thanks!
- Anonymous6 years agoNot applicable
hey v-ljerr-msft
It is posible to use the function Related ( ) you use there but in a many to many relationship?
Thanks.