Forum Discussion

newbie9's avatar
newbie9
Helper I
2 years ago
Solved

filter context not working

Hi,   my problem is I need the distinct count of sport with string consist of ball/ team but only for won = 1       the orginal column only contain team,sport,alias,name won & current count a...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi newbie9 ,

    You can create two measures as below to get it, please find the details in the attachment.

    Won = 
    VAR _alias =
        SELECTEDVALUE ( 'table'[alias] )
    VAR _player =
        CALCULATE (
            MAX ( 'table2'[player] ),
            FILTER ( 'table2', 'table2'[alias] = _alias )
        )
    RETURN
        IF ( ISBLANK ( _player ), 0, 1 )
    Expected count =
    VAR _team =
        SELECTEDVALUE ( 'table'[team] )
    RETURN
        CALCULATE (
            DISTINCTCOUNT ( 'table'[sport] ),
            FILTER (
                ALLSELECTED ( 'table' ),
                'table'[team] = _team
                    && CONTAINSSTRING ( 'table'[sport], "*ball*" )
                    && [Won] = 1
            )
        )

    Best Regards