Forum Discussion
Calculate count of rows
- 8 years ago
Dear Zubair_Muhammad, Thanks again for your help. It's indeed almost perfect solution :-)
I made minor changes as I could not get SELECTEDVALUE function. Rest is all good.
Match Count of Winner Team =
VAR winnerteam =
SELECTCOLUMNS( matches,"winner2",matches[winner])
RETURN
CALCULATE ( COUNTROWS ( ALLSELECTED ( Matches ) ), Matches[Team1] = winnerteam )
+ CALCULATE ( COUNTROWS ( ALLSELECTED ( Matches ) ), Matches[Team2] = winnerteam ) - 8 years ago
I don't think this is an issue really, you'd better post these questions in the community forum.
But anyway, for this to work you should have a separate table in your model containing the teams, and have relationships both from team1 to the team table and from team2 to the team table. Now,
Match_Count = [Count1] + [Count2]
where
Count1 = COUNTROWS(Data)
and
Count2 = CALCULATE(COUNTROWS(Data), USERELATIONSHIP(Data[Team2], Team[Team]))
assuming your main data table is called Data, and your team table is called Team with column Team.
This also assumes that no team plays against itself, which seems reasonable.