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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
nmckeown1
Helper I
Helper I

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
Super User
Super User

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
Super User
Super User

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
Super User
Super User

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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