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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
nmckeown1
Helper II
Helper II

TopN time dax for total calls

I've built a measure that calculates what TopN peak times (hours) during the day we have max calls. This DAX spits out the times of the top 4 hours most calls were answered. 

 

DAX Peak time Calls 4 hours =
VAR TotalSalesPerHour =
SUMMARIZE (
'Aggregated Daily',
'Aggregated Daily'[Time Hour],
"TotalCalls", [Calls measure]
)
VAR Result =
CONCATENATEX (
TOPN ( 4, TotalSalesPerHour, [TotalCalls] ),
'Aggregated Daily'[Time Hour],
", ",
[TotalCalls]
)
RETURN
Result

 

 I now need to calculate the actual total number of calls, within just those top4 times. I tried editing the return variable but this didn't work:

RETURN
CALCULATE(Totalsalesperhour,FILTER('Aggregated Daily','Aggregated Daily'[Time Hour] = RESULT)) 
Any thoughts?
1 ACCEPTED SOLUTION
saud968
Memorable Member
Memorable Member

DAX Peak time Calls 4 hours =
VAR TotalSalesPerHour =
SUMMARIZE (
'Aggregated Daily',
'Aggregated Daily'[Time Hour],
"TotalCalls", [Calls measure]
)
VAR Top4Hours =
TOPN ( 4, TotalSalesPerHour, [TotalCalls] )
VAR Top4HoursList =
SELECTCOLUMNS(Top4Hours, 'Aggregated Daily'[Time Hour])
VAR Result =
CALCULATE (
SUM('Aggregated Daily'[Calls measure]),
'Aggregated Daily'[Time Hour] IN Top4HoursList
)
RETURN
Result

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

View solution in original post

3 REPLIES 3
saud968
Memorable Member
Memorable Member

DAX Peak time Calls 4 hours =
VAR TotalSalesPerHour =
SUMMARIZE (
'Aggregated Daily',
'Aggregated Daily'[Time Hour],
"TotalCalls", [Calls measure]
)
VAR Top4Hours =
TOPN ( 4, TotalSalesPerHour, [TotalCalls] )
VAR Top4HoursList =
SELECTCOLUMNS(Top4Hours, 'Aggregated Daily'[Time Hour])
VAR Result =
CALCULATE (
SUM('Aggregated Daily'[Calls measure]),
'Aggregated Daily'[Time Hour] IN Top4HoursList
)
RETURN
Result

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

This worked perfect, thank you!!

FreemanZ
Community Champion
Community Champion

hi @nmckeown1 ,

 

try like:

DAX Peak time Calls 4 hours =

VAR TotalSalesPerHour =

ADDCOLUMNS(

    SUMMARIZE (

       'Aggregated Daily',

      'Aggregated Daily'[Time Hour]

    ),

    "TotalCalls", [Calls measure]

)

VAR _hours = 

SUMMARIZE(

    TOPN ( 4, TotalSalesPerHour, [TotalCalls]),

    'Aggregated Daily'[Time Hour]

)

VAR Result =

CALCULATE(

    [Calls measure],

    'Aggregated Daily'[Time Hour] IN _hours

)

RETURN Result

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.