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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
DebbieE
Community Champion
Community Champion

DAX to find the MAX Number of a summed column

Another DX Query Im struggling with. I want to end up with a card. Heres some fake data

 

Ref Stage Person Hours
1     1        1            3 
1     2        1            5
1     3         1           1
1     3         2           4
1     4        1            7
1     6        2            4
1     7        3            3
2    1         4            7

 

First of all i want to SUM Hours By Ref and Person. So Person 1 for Ref 1 woulkd be 15 hours
And the card would show the MAX Hours.  So for this example Its person 1 with 15 Hours so this would show in the card

 

I dont really know where to start on this one.  Here is the SQL Query that works on the data

SELECT MAX(Hours)
FROM (

select Ref, Person 
SUM(Hours ) AS Hours
FROM table1 
GROUP BY Ref, Person
) a
GROUP BY [Incident Ref]

 

The report is already filtered on a single Reference

 

 

 

3 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@DebbieE try following two measures

 

first get sum by ref/person and then find the max hours

 

Sum = CALCULATE( SUM( Table3[hours] ), ALLEXCEPT( Table3, Table3[person], Table3[ref] ) )

MAX = MAXX( Table3, [Sum] )



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.

View solution in original post

tex628
Community Champion
Community Champion

Nevermind the previous measure, it's incorrect 🙂

Here:

Measure = 
SUMX(
TopN( 1;
    Summarize(
        'Table';
        'Table'[Ref];
        'Table'[Person];
        "Value" ; Sum('Table'[Hours])
); [Value] ); 
[Value])

Connect on LinkedIn

View solution in original post

DebbieE
Community Champion
Community Champion

I just dont know what Im doing wrong.

 

On my actual data set I have 1 ref and the max hour is 4.4 hours

However this shows 17.60 hours. I cant even figure out where its getting that number from

 

Thank goodness I changed it to this and it works

 

Max Duration Hours lost = MAXX(
TOPN(1,SUMMARIZE('fact OMSIncident','dim OMSIncident'[Incident Ref],
'dim OMSInterruptions'[Pro Number],
"Value",SUM('fact OMSIncident'[Duration (Hours)])
),[Value]),
[Value])

 

 

View solution in original post

4 REPLIES 4
tex628
Community Champion
Community Champion

Try this:
 

Measure = 
Calculate(
Selectedvalue([Person]) & " with " & Selectedvalue([Value]);
TopN( 1;
Summarize(
'Table';
'Table'[Ref];
'Table'[Person];
"Value" ; Sum('Table'[Hours])
); [Value] 
))

 

Dont know if it will work 😄 
The red values should be values created in the summarize statement. 

Let me know if it works!


Connect on LinkedIn
parry2k
Super User
Super User

@DebbieE try following two measures

 

first get sum by ref/person and then find the max hours

 

Sum = CALCULATE( SUM( Table3[hours] ), ALLEXCEPT( Table3, Table3[person], Table3[ref] ) )

MAX = MAXX( Table3, [Sum] )



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.

tex628
Community Champion
Community Champion

Nevermind the previous measure, it's incorrect 🙂

Here:

Measure = 
SUMX(
TopN( 1;
    Summarize(
        'Table';
        'Table'[Ref];
        'Table'[Person];
        "Value" ; Sum('Table'[Hours])
); [Value] ); 
[Value])

Connect on LinkedIn
DebbieE
Community Champion
Community Champion

I just dont know what Im doing wrong.

 

On my actual data set I have 1 ref and the max hour is 4.4 hours

However this shows 17.60 hours. I cant even figure out where its getting that number from

 

Thank goodness I changed it to this and it works

 

Max Duration Hours lost = MAXX(
TOPN(1,SUMMARIZE('fact OMSIncident','dim OMSIncident'[Incident Ref],
'dim OMSInterruptions'[Pro Number],
"Value",SUM('fact OMSIncident'[Duration (Hours)])
),[Value]),
[Value])

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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