Reputation: 43
In BI, is there a way to write a function that looks at Name 2 and pulls the score from the second column for that individual? Any help would be greatly appreciated!
Name | Score | Name 2 | Score 2 |
---|---|---|---|
Bob | 100 | Sue | |
Sue | 80 | Nick | |
Nick | 50 | Bob |
Upvotes: 2
Views: 17625
Reputation: 8148
If you want to implement it as a calculated column in your data model:
Score 2 =
VAR Current_Name = Table[Name 2]
RETURN
CALCULATE ( SUM ( Table[Score] ), ALL ( Table ), Table[Name] = Current_Name )
If you want to implement it as a measure:
Score 2 =
CALCULATE (
SUM ( Table[Score] ),
ALL ( Table )
Table[Name] IN VALUES ( Table[Name 2] )
)
Upvotes: 3
Reputation: 4346
You sure can with the following measure
_score2 =
SUMX (
'fact',
VAR _0 = 'fact'[Name 2]
VAR _1 =
CALCULATE (
CALCULATE ( SUM ( 'fact'[Score] ), 'fact'[Name] = _0 ),
ALL ( 'fact' )
)
RETURN
_1
)
Upvotes: 0