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

Finding a MAX value of a summarized table in DAX

I have the following DAX which resulted in the table below. I would like to see a result showing the max value in the summarized table. I attempted to wrap it in MAX, MAXX, and alternatively store the MAX'd table in a separate variable and then return that but failed.

 

 

Min Talk Time =
    VAR ct_TalkTime = SUMMARIZE('f_Call Metrics','f_Call Metrics'[Agent], "AVG Talk Time", AVERAGE('f_Call Metrics'[Average Handle Time]))
RETURN
    ct_TalkTime 

 

 

 

 

AgentAVG Talk Time
Aubriella Maddox0.008394
Connor Oliver0.008659
Luke Rosales0.010166
Jocelyn Vazquez0.008448
Esme Mullen0.007051
Sara Evans0.00831
Elias Marshall0.012287
Donovan Christian0.008265

 

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @hobosapien 

This is how I would suggest writing a measure Max time per Agent to return the max value of the average of Average Handle Time per agent:

Max Time per Agent =
MAXX (
    VALUES ( 'f_call Metrics'[Agent] ),
    CALCULATE ( AVERAGE( 'f_Call Metrics'[Average Handle Time] ) )
)

 

Alternatively, you could first create this measure:

Average Time =
AVERAGE( 'f_Call Metrics'[Average Handle Time] )

then use it within Max Time per Agent:

Max Time per Agent =
MAXX (
    VALUES ( 'f_call Metrics'[Agent] ),
    [Average Time]
)

 

Does this work for you?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

3 REPLIES 3
OwenAuger
Super User
Super User

Hi @hobosapien 

This is how I would suggest writing a measure Max time per Agent to return the max value of the average of Average Handle Time per agent:

Max Time per Agent =
MAXX (
    VALUES ( 'f_call Metrics'[Agent] ),
    CALCULATE ( AVERAGE( 'f_Call Metrics'[Average Handle Time] ) )
)

 

Alternatively, you could first create this measure:

Average Time =
AVERAGE( 'f_Call Metrics'[Average Handle Time] )

then use it within Max Time per Agent:

Max Time per Agent =
MAXX (
    VALUES ( 'f_call Metrics'[Agent] ),
    [Average Time]
)

 

Does this work for you?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

That worked, thank you! Although I wonder why I can't reference the summarized table and find the MAX that way? Is there some limitation referencing a table that was created within the same measure?

I'm glad it worked 🙂

 

You certainly can reference a summarized table if you like. I tend to avoid this approach where possible because the summarized table is materialized in memory when the measure is evaluated, which will have an impact on performance.

 

Firstly, a couple of things to note:

  • In general you should not add extended columns with the SUMMARIZE function itself. Instead, use ADDCOLUMNS ( SUMMARIZE ( ... ) ). See this article.
  • When using ADDCOLUMNS/SUMMARIZE, the extended column expressions must be wrapped in CALCULATE (context transition).
  • If there is a single grouping column specified within SUMMARIZE and it is from the same table as the first argument, you can just use VALUES with a single column argument (if there are no extended columns).
    In other words, SUMMARIZE ( tbl, tbl[col] ) and VALUES ( tbl[col] ) are equivalent.

Taking the above into account, you could write your measure as:

 

 

Max Time per Agent =
VAR AgentTime =
    ADDCOLUMNS (
        VALUES ( 'f_call Metrics'[Agent] ), -- or SUMMARIZE ( 'f_call Metrics', 'f_call Metrics'[Agent] )
        "AVG Talk Time",
        CALCULATE ( AVERAGE ( 'f_Call Metrics'[Average Handle Time] ) )
    )
VAR MaxAgentTime =
    MAXX ( AgentTime, [AVG Talk Time] )
RETURN
    MaxAgentTime

 

 

If you did want to use SUMMARIZE itself to add columns (though I would not recommend this), it would look like this:

 

 

Max Time per Agent =
VAR AgentTime =
    SUMMARIZE (
        'f_call Metrics',
        'f_call Metrics'[Agent],
        "AVG Talk Time",
        AVERAGE ( 'f_Call Metrics'[Average Handle Time] ) -- CALCULATE not required
    )
VAR MaxAgentTime =
    MAXX ( AgentTime, [AVG Talk Time] )
RETURN
    MaxAgentTime

 

 

In both cases, you don't have to create the AgentTime variable. You could just move the AgentTime expression inside MAXX.

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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