Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Card trouble - need a DAX solution

Need help with a DAX formula. I am trying to add a filter to a card to achieve "Blank" cards when the condition is not met.  The condition is that 5 players or more must play in order for the card to show the data.

 

Weighted average score is a measure of how all players did in a particular sport on a particular day (governed by slicers on the page) - 

WeightedAvgScore = SUMX([PlayerScore] * [Weight]) / SUMX([Weight])

 

# of players depends on the sport and the day-

I created the #ofplayers flag as a measure to see if 1's and 0's could help with filtering. It did not. 

 

TeamSportWeightedAvgScore# of players#ofplayersMeasure (flag)
School ASoccer20101
School ATennis3420
School ABaseball63121
School BSoccer123101
School BFootball2330
School BBaseball26121
School CFootball36101
School CTennis3220
School CBaseball23121

 

Desired result on card is the last column:

Result Display when # of players > 5
TeamSportWeightedAvgScore CARD
School ASoccer20
School ATennisBlank
School ABaseball63
School BSoccer123
School BFootballBlank
School BBaseball26
School CFootball36
School CTennisBlank
School CBaseball23

 

This forumla did not filter properly - 

 

=SUMX(FILTER(Table1
CALCULATE(DISTINCTCOUNT([PlayerID),[PlayerID]>15)),
SUMX([PlayerScore] * [Weight]) / SUMX([Weight])

 

Please help! 

  • Anonymous - 

    5 or more measure =
      VAR __Team = MAX([Team])
      VAR __Sport = MAX([Sport])
      VAR __5orMore = IF([# of players] >=5,1,0)
    RETURN
      IF(__5orMore,[WeightedAverage],BLANK())

    Assumes a WeightedAverage measure. Do you need help with that as well? 

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Anonymous - 

    5 or more measure =
      VAR __Team = MAX([Team])
      VAR __Sport = MAX([Sport])
      VAR __5orMore = IF([# of players] >=5,1,0)
    RETURN
      IF(__5orMore,[WeightedAverage],BLANK())

    Assumes a WeightedAverage measure. Do you need help with that as well? 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Yay! Thank you Greg! It worked on the second try.

  • Anonymous , Try like

    Measure =
    var _dist =CALCULATE(DISTINCTCOUNT([PlayerID]))
    return
    SUMX(FILTER(Summarize(Table1,Table1[Team] ,Table1[Sport],"_1",_dist, "_2",SUMX(Table,[PlayerScore] * [Weight]),"_3",SUMX([Weight])),[_1]_dist>15),divide([_2] /[_3] ))

    • Anonymous's avatar
      Anonymous
      Not applicable

      Unfortunately I could not get this to work. Thank you for the reply though.