cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jpereztang Regular Visitor
Regular Visitor

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

Accepted Solutions
Gravanita Regular Visitor
Regular Visitor

Re: Average of grouped max

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

Super User
Super User

Re: Average of grouped max

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
Gravanita Regular Visitor
Regular Visitor

Re: Average of grouped max

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

jpereztang Regular Visitor
Regular Visitor

Re: Average of grouped max

at first sight it fits perfectly. Thank you.

Super User
Super User

Re: Average of grouped max

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

jpereztang Regular Visitor
Regular Visitor

Re: Average of grouped max

@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

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)