Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
chandi
New Member

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! 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@chandi - 

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? 


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@chandi , 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] ))

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

Greg_Deckler
Super User
Super User

@chandi - 

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? 


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors