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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Idigorasu
Frequent Visitor

Get median of rows with same values

Hi,

 

I have a table with data like this:

Screenshot_2.jpg

What I need is to get the median of each row that has the same Question and Teacher.

So, Question 1 for John would be: 8 + 5 = 13/2 = 6,5

 

Is this possible?

1 ACCEPTED SOLUTION
JarroVGIT
Resident Rockstar
Resident Rockstar

Hi @Idigorasu ,

Please remember never post pictures of tables, it is completely useless to the people who are helping you and now we have to type over your date (which could have been avoided and sped up the process of helping you :)).

It isn't clear if you want a calculated column or a measure so I assume a calculated column for now. 

The second thing is the word 'median' which means something else than 'average'. The median of a set of numbers is that number where half the numbers are lower and half the numbers are higher. The average of a set of numbers is the total of those numbers divided by the number of items in that set. The median and the average might be close, but they could also significantly different. It all depends on the numbers. 

In your case, you are looking at the average ( ( 8 + 5 ) / 2) = 13. So I am going to assume you meant average and not median. 

The calculated column dax is this:

AverageTeacherQuestion = 
VAR _curTeacher = Table2[Teacher]
VAR _curQuestion = Table2[Question]
RETURN
AVERAGEX(FILTER(Table2, Table2[Question] = _curQuestion && Table2[Teacher] = _curTeacher), [Score])

Resulting in this:

image.png

You can find my PBIX here, it is Table2 and you can ignore other tables (these are for other questions). Let me know if this works for you!

 

Kind regards

Djerro123

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

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





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

Proud to be a Super User!




View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @Idigorasu.,

You can use the following measure formula to get average aggregate based on filtered table records and current row contents 'Question','Teacher' categories labels.

Measure =
CALCULATE (
    AVERAGE ( Table[Score] ),
    ALLSELECTED ( Table ),
    VALUES ( Table[Question] ),
    VALUES ( Table[Teacher] )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
JarroVGIT
Resident Rockstar
Resident Rockstar

Hi @Idigorasu ,

Please remember never post pictures of tables, it is completely useless to the people who are helping you and now we have to type over your date (which could have been avoided and sped up the process of helping you :)).

It isn't clear if you want a calculated column or a measure so I assume a calculated column for now. 

The second thing is the word 'median' which means something else than 'average'. The median of a set of numbers is that number where half the numbers are lower and half the numbers are higher. The average of a set of numbers is the total of those numbers divided by the number of items in that set. The median and the average might be close, but they could also significantly different. It all depends on the numbers. 

In your case, you are looking at the average ( ( 8 + 5 ) / 2) = 13. So I am going to assume you meant average and not median. 

The calculated column dax is this:

AverageTeacherQuestion = 
VAR _curTeacher = Table2[Teacher]
VAR _curQuestion = Table2[Question]
RETURN
AVERAGEX(FILTER(Table2, Table2[Question] = _curQuestion && Table2[Teacher] = _curTeacher), [Score])

Resulting in this:

image.png

You can find my PBIX here, it is Table2 and you can ignore other tables (these are for other questions). Let me know if this works for you!

 

Kind regards

Djerro123

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

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





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

Proud to be a Super User!




Hi @JarroVGIT ,

 

  1. I apologize, I didn't think about the picture. Lesson learnt!
  2. Yes, you are right. I am looking for the average, not the median.
  3. That is formula I was looking for. Thank you so much! 

I just started with PowerBI and this community has helped me so much, thank you for your work.

Have a nice day.

 

 

Great to hear and have fun with your learning journey! It really is just a very nice tool 🙂 if you have any other questions, just tag me in your message 🙂
Kind regards,
Dkerro123




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

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.