Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
I have the 3 first columns, and I want to get the blue one. The values are obtained by comparing grades to grade averages of each area. How to do it?
Solved! Go to Solution.
Hi @Zyg_D ,
Try this one:
Hi @Zyg_D
Create a new calculated column in your table:
above_below =
VAR area_avg_ =
CALCULATE ( AVERAGE ( Table1[grade] ), ALLEXCEPT ( Table1, Table1[area] ) )
RETURN
SWITCH (
TRUE (),
Table1[grade] > area_avg_, "above average",
Table1[grade] = area_avg_, "average",
Table1[grade] < area_avg_, "below average"
)
Please mark the question solved when done and consider giving kudos if posts are helpful.
Cheers
@AlB wrote:Create a new calculated column in your table:
above_below =
VAR area_avg_ =
CALCULATE ( AVERAGE ( Table1[grade] ), ALLEXCEPT ( Table1, Table1[area] ) )
RETURN
SWITCH (
TRUE (),
Table1[grade] > area_avg_, "above average",
Table1[grade] = area_avg_, "average",
Table1[grade] < area_avg_, "below average"
)
Although I like that you properly formatted your answer, it evaluated as error to me.
Hi @Zyg_D ,
Try this one:
@Greg_Deckler wrote:
above/below =
VAR __grade = MAX('Table'[grade])
VAR __area = MAX('Table'[area])
VAR __average = AVERAGEX(FILTER(ALL('Table'),[area]=__area),[grade])
IF(__grade >= __average,"above average","below average")
Sorry, even after adding RETURN before IF it yields wrong results - always above average.
Because it is a measure and you are probably trying to use it in a column.
Column form:
above/below =
VAR __grade = [grade]
VAR __area = [area]
VAR __average = AVERAGEX(FILTER('Table',[area]=__area),[grade])
RETURN
IF(__grade >= __average,"above average","below average")
@Greg_Deckler wrote:Because it is a measure and you are probably trying to use it in a column.
Column form:
above/below =
VAR __grade = [grade]
VAR __area = [area]
VAR __average = AVERAGEX(FILTER('Table',[area]=__area),[grade])
RETURN
IF(__grade >= __average,"above average","below average")
Is performance-wise measure better than calculated column?
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 55 | |
| 34 | |
| 32 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 75 | |
| 72 | |
| 38 | |
| 35 | |
| 25 |