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
jpereztang
Helper I
Helper I

Average of grouped max

Hello guys,

 

I have troubles trying to find way to solve this calculation. I need the average of max delivered days values grouped by num order

 

help1.png

 

I try with this measure

 

delivered days grouped = SUMX(VALUES(Time[NumOrder])
                    ,MAX(Time[Delivereddays])
)

 and then 

 

 

 

 

avg days = DIVIDE([delivered days grouped],[Orders],0)

 

 

But what i obtain is 11 and i dont know why, please can you help me?

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @jpereztang

You can try this:

=
VAR x =
    SUMMARIZE ( 'Time'; 'Time'[Num Order]; "dd"; MAX ( 'Time'[Delivered Days] ) )
RETURN
    AVERAGEX ( x; [dd] )

step1.JPG

View solution in original post

AlB
Super User
Super User

Hi @jpereztang

 

If you just wrap a CALCULATE around the MAX() in your first measure it should work. The current problem is that with no calculate there is no context transition and MAX() always yields 11, the max for the full [Delivered days] column. 

 

View solution in original post

4 REPLIES 4
AlB
Super User
Super User

Hi @jpereztang

 

If you just wrap a CALCULATE around the MAX() in your first measure it should work. The current problem is that with no calculate there is no context transition and MAX() always yields 11, the max for the full [Delivered days] column. 

 

@AlB this also works, i couldn't figure out why this measure doesn't work if in the past work for similar scenario and as you say is because i was omitted calculate. Smiley Embarassed   Thank you! Smiley Very Happy

Anonymous
Not applicable

Hi @jpereztang

You can try this:

=
VAR x =
    SUMMARIZE ( 'Time'; 'Time'[Num Order]; "dd"; MAX ( 'Time'[Delivered Days] ) )
RETURN
    AVERAGEX ( x; [dd] )

step1.JPG

at first sight it fits perfectly. Thank you.

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.