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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply

DAX - Average only on Distinct Rows and with Year filter

Hi, I am working on DAX Query where I need to calculate the Average only from the distinct rows and with filter

 

For example, this is my raw table

 

NameRoll_noYearMarks
a1201493
a1201493
a1201493
b2201592
b2201491
b2201491
b2201594
c3201594
c3201680
c3201481
c3201481
c3201675
c3201776
d4201545
d4201646
d4201450
d4201450
d4201646
d4201776

 

from this, we could see that there are duplicates of same name with roll num in same year. My goal is to not to consider the duplicates while calculating the average of marks.

My end goal is to get an average of the year filter - 2014 with only distinct values

 

like this

 

 

NameRoll_noYearMarks
a1201493
b2201491
c3201481
d4201450
    
avg  78.75

 

please help me to create the dax

5 REPLIES 5

Hi, thanks for sharing, 

 

But how to apply year filter on this. I need to calculate only for 2014. How apply filter for year? 

 

And may I know why you have used marks column in the distinct? Shouldn't it be the name/roll num? 

Mahesh0016_0-1670932023901.png

 

If you want to show only 2014 Avg marks so you give visual level filter in filter by year to 2014. and why i use distinct marks column because of we want to avg of distinct mark so i have use column as a table .

I got the filter part. 

But now, my conecern is the disctinct values. I need to consider the name / roll num column for taking distinct values right. I can have 2 students getting same marks. If I take marks as distinct, my result will go wrong, right? 

My aim is to consider the distinct values of name/roll num and calculate the average. 

The dax you shared is helping close to the results, But I am concerned about the Distinct part. Please help me

Mahesh0016
Super User
Super User

Mahesh0016_0-1670930763281.png

Avg Marks = AVERAGEX(DISTINCT(Student_Marks[Marks]),Student_Marks[Marks])
 
Hello @jayasurya_prud ,
Try Above Solution..... If it is helpful for you so please accept as Solution marks .

Thank You!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.