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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply

Retrieve single column value based on calculation on another column

Hello,

 

This is my Power Bi table where the column "Calls" is calculated column ( a kind of counter). I want to get Local Start Hour when the highest number of Calls were started for a selected name.

I've been trying to summarize table by Name and Local Start Hours in order to calculate total # of calls started on every hour, but I couldn't get what I wanted.

 

For example: If I select "John Smith" and an appropriate date range the result can be "10:00 AM" which means that John Smith made the most calls where Local Start Hour is 10:00.

 

Table example:

NameDateLocal TimeLocal Start HourCalls
John Smith12/2/201910:35 AM10:00:001
John Smith12/2/201910:36 AM10:00:001
John Smith12/2/201911:14 AM11:00:001
David Johnson12/2/201911:15 AM11:00:001
David Johnson12/3/201911:21 AM11:00:001
David Johnson12/3/201911:28 AM11:00:001
David Johnson12/3/201911:50 AM11:00:001
David Johnson12/3/201912:30 PM12:00:001
David Johnson12/3/201912:36 PM12:00:001

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Perhaps:

 

Measure 3 = 
    VAR __Name = MAX('Table7'[Name])
    VAR __Table = SUMMARIZE('Table7',[Name],[Local Start Hour],"__Calls",SUM([Calls]))
    VAR __Max = MAXX(FILTER(__Table,[Name] = __Name),[__Calls])
RETURN
    MINX(FILTER(__Table,[Name] = __Name && [__Calls] = __Max),[Local Start Hour])

 

Page 5, Table 7



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
VasTg
Memorable Member
Memorable Member

@lazzarjovvch74 

 

Please follow the steps.

 

Step 1: Group by your table as below.

 

Cap11.PNG

 

Create a DAX measure as follows.

 

Measure = CALCULATE(MAX('Table'[Local Start Hour]), FILTER('Table','Table'[Sum of Calls]=MAX('Table'[Sum of Calls])))

 

 

 

 

cap12.PNG

 

If this helps, mark it as a solution.

Kudos are nice too.

Connect on LinkedIn

@lazzarjovvch74 Although @Greg_Deckler  has already provided  a solution, sharing another thought on this

 

Add following measure

 

Max hour = 
CALCULATE( 
MAX ( HR[Local Start Hour] ),  
TOPN( 1, ALLSELECTED( HR[Local Start Hour] ), [Call], DESC ) 
) 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k thank you for submitting your solution.

At the end of your code, I couldn't use just "Calls", but I had to use an aggregation function. Just to remind you that "Calls" is calculated column, not measure. But the code below doesn't retrieve the correct result yet.

Max hour = CALCULATE(MAX(Table1[Local Start Hour]), TOPN(1, ALLSELECTED(Table1[Local Start Hour]), SUM(Table1[Calls]), DESC))

 

@lazzarjovvch74 sorry I missed to mention that Call is a measure

 

 

Call = SUM ( HR[Calls] )

Max Hour = 
CALCULATE( 
MAX ( HR[Local Start Hour] ),  
TOPN( 1, ALLSELECTED( HR[Local Start Hour] ), [Call], DESC ) 
) 

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k thank you. Your solution works as well!

 

 

Greg_Deckler
Community Champion
Community Champion

Perhaps:

 

Measure 3 = 
    VAR __Name = MAX('Table7'[Name])
    VAR __Table = SUMMARIZE('Table7',[Name],[Local Start Hour],"__Calls",SUM([Calls]))
    VAR __Max = MAXX(FILTER(__Table,[Name] = __Name),[__Calls])
RETURN
    MINX(FILTER(__Table,[Name] = __Name && [__Calls] = __Max),[Local Start Hour])

 

Page 5, Table 7



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.