Forum Discussion
Saxon10
Post Prodigy
5 years agoCalculate distinct based on the two columns
In data table I have 3 columns are Team, Id and result. In result column contain win, loss and no result. If same team and id contain win, loss and no result then return "Multiple". If same team a...
- 5 years ago
Hi,
NewColumn = VAR MyTeam = 'Table'[Team] VAR MyID = 'Table'[ID] VAR MyTeamIDWins = CALCULATE ( COUNTROWS ( FILTER ( 'Table', 'Table'[Team] = MyTeam && 'Table'[ID] = MyID ) ), 'Table'[Result] = "Win" ) VAR MyTeamIDLosses = CALCULATE ( COUNTROWS ( FILTER ( 'Table', 'Table'[Team] = MyTeam && 'Table'[ID] = MyID ) ), 'Table'[Result] = "Loss" ) RETURN SWITCH ( 1 * ( MyTeamIDWins > 0 ) + 2 * ( MyTeamIDLosses > 0 ), 1, "Win", 2, "Loss", 3, "Multiple" )Regards
- 5 years ago
How about this?
Desired Report = VAR Results = CALCULATETABLE ( VALUES ( Table1[Result] ), ALLEXCEPT ( Table1, Table1[Team], Table1[ID] ), Table1[Result] <> "No Result" ) RETURN SWITCH ( TRUE (), COUNTROWS ( Results ) = 0, "No Result", COUNTROWS ( Results ) = 1, Results, COUNTROWS ( Results ) > 1, "Multiple" ) - 5 years ago
Thanks for your reply and solution for Jos_Woolley and @AlexisOlson and sorry for the late reply.
Both solutions are working well.
Jos_Woolley
Solution Sage
5 years agoHi,
NewColumn =
VAR MyTeam = 'Table'[Team]
VAR MyID = 'Table'[ID]
VAR MyTeamIDWins =
CALCULATE (
COUNTROWS ( FILTER ( 'Table', 'Table'[Team] = MyTeam && 'Table'[ID] = MyID ) ),
'Table'[Result] = "Win"
)
VAR MyTeamIDLosses =
CALCULATE (
COUNTROWS ( FILTER ( 'Table', 'Table'[Team] = MyTeam && 'Table'[ID] = MyID ) ),
'Table'[Result] = "Loss"
)
RETURN
SWITCH (
1 * ( MyTeamIDWins > 0 ) + 2 * ( MyTeamIDLosses > 0 ),
1, "Win",
2, "Loss",
3, "Multiple"
)Regards