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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Return the average of a virtual table containing max values

I feel like there is something obvious that I am missing. 

 

As an example, my starter data has a column for Editor, a column for "Book ID" and a "Revision Number" column. There is a row for each revision on a book. 

 

EditorBook IDRevision Number
Sam475113
Jenny55347
Lee48391
Robin40270
Lee44200
Sam475114
Jenny55348
Lee48392
Sam66780
Lee44201
Sam475115
Jenny55349
Lee48393
Sam66781
Lee44202
Sam475116
Jenny553410
Lee48394
Robin98780
Lee44203

 

I want to first find the highest revision number for each book, like so:

EditorBook IDMax Revision Number Per Book
Sam475116
Jenny553410
Lee48394
Robin40270
Lee44203
Sam66781
Robin98780

 

For my result table, I want to show the editors and their average number of revisions per book:

EditorAverage Revisions Per Book
Sam8.5
Jenny10
Lee3.5
Robin0


I am able to somewhat build the middle table in DAX studio like so:
EVALUATE

SUMMARIZECOLUMNS(
    'Book Drafts'[Book ID]
    , "Max Revision Number Per Book", MAX('Book Drafts'[Revision Number])
)

It doesn't have the editor names, but it does have the highest revision number for each book ID.


However, I need to get to the average of book drafts for each editor. I tried building this measure based off another topic I found in this forum:

VAR MaxBookRevision =

    ADDCOLUMNS ( // We must create a virtual table that shows the max book revision per book ID.

        VALUES( 'Book Drafts'[Book ID] ),

        "@MaxBookRevision", MAX('Book Drafts'[Revision Number]) 

    ) // This returns the highest draft of all of the books for every book ID

   

VAR FilteredBookRevision = FILTER ( MaxBookRevision, [@MaxBookRevision] >= 0 ) // We don't necessarily want to filter out books with zero revisions. We are building this variable so AVERAGEX() has something to iterate over.

 

VAR Result = // Iterator required to aggregate the @MaxBookRevision column        

    AVERAGEX ( FilteredBookRevision, [@MaxBookRevision] )
Return
Result


Unfortunately, when I build a matrix table with Editor in Rows and put the above measure in Values, it seems to return the highest number of revisions for each editor rather than the average revision number for each editor.

What are your thoughts?

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

These measures work

Max revision number = MAX(Data[Revision Number])
Measure = AVERAGEX(VALUES(Data[Book ID]),[Max revision number])

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

These measures work

Max revision number = MAX(Data[Revision Number])
Measure = AVERAGEX(VALUES(Data[Book ID]),[Max revision number])

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

You are absolutely right. I can't believe I was obsessing about these needlessly complex ideas. Thank you for posting this.

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors