cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Comparing to category average

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?

image.png

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: Comparing to category average

Hi @Zyg_D ,

 

Try this one:

 

Column =
VAR _avg = CALCULATE(AVERAGE('Table (2)'[Grade]); FILTER('Table (2)'; 'Table (2)'[Area] = EARLIER('Table (2)'[Area])))
RETURN IF('Table (2)'[Grade] < _avg; "Below Average";
IF('Table (2)'[Grade] = _avg; "Average";
"Above Average")
)
 
This column is static, if you need it dynamically you can use this link as reference:
 
 
Did I answer your question? Mark my post as a solution!
Ricardo
 

Did I answer your question? Mark my post as a solution!
Ricardo

View solution in original post

7 REPLIES 7
Highlighted
Super User IV
Super User IV

Re: Comparing to category average

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")

---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Community Champion
Community Champion

Re: Comparing to category average

Hi @Zyg_D ,

 

Try this one:

 

Column =
VAR _avg = CALCULATE(AVERAGE('Table (2)'[Grade]); FILTER('Table (2)'; 'Table (2)'[Area] = EARLIER('Table (2)'[Area])))
RETURN IF('Table (2)'[Grade] < _avg; "Below Average";
IF('Table (2)'[Grade] = _avg; "Average";
"Above Average")
)
 
This column is static, if you need it dynamically you can use this link as reference:
 
 
Did I answer your question? Mark my post as a solution!
Ricardo
 

Did I answer your question? Mark my post as a solution!
Ricardo

View solution in original post

Highlighted
Super User III
Super User III

Re: Comparing to category average

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 

SU18_powerbi_badge

 

 

Highlighted
Helper III
Helper III

Re: Comparing to category average


@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.

Highlighted
Helper III
Helper III

Re: Comparing to category average


@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. 

Highlighted
Super User IV
Super User IV

Re: Comparing to category 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")

 


---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Helper III
Helper III

Re: Comparing to category 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?

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors