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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Average of distinct ID - two columns

I need have a measure made that gives me average of days.

I have a column wiht ID and a column with days spent,

Example

 

UID                DAYS       

1                    32

2                    5

2                    5

4                    15

5                    33

6                    12

6                    12

8                    5

9                    5

10                  15

 

Average should be 15.25

 

I have tried the following solution http://community.powerbi.com/t5/Desktop/Average-based-on-distinct-values-in-another-column/m-p/60122...

But doesnt seem to work for me 😕

 

1 ACCEPTED SOLUTION
MattAllington
Community Champion
Community Champion

How about this

 

=Averagex(values(table[UID]), average(table[days]))



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

3 REPLIES 3
MattAllington
Community Champion
Community Champion

How about this

 

=Averagex(values(table[UID]), average(table[days]))



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
Anonymous
Not applicable

Thanks Matt, I have tested 2 periods and looks like it works - Thanks a lot

Do you know how it works?

 

Averagex is an iterator.  It steps through a table - in this case it is a single column table containing all the unique UIDs created by values(table[UID].  For each unique UID, the formula average(table[days]) is evaluated.  Assuming each unique UID has the same value for [days], the average will be the same as the value.  After each UID has been evaluated, AVERAGEX works out the average of the values.



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors