Find maximum value in a column filtered by criteria

Nerdio

New Member
Joined
Dec 5, 2011
Messages
14
I have a table that has columns of Date, Hour, Person, and 'Value'. It would look something like this.

DateHourPersonValue
1-Apr-20211Fred7
1-Apr-20211Joe9
1-Apr-20211Paul5
1-Apr-20212Fred11
1-Apr-20212Paul6
2-Apr-20212Joe13

What I want to know is what is the greatest value for each hour. The Date and Person fields above just discriminate the specific hours. So,
the output would be something like this.

HourValue (Max)
19
213

What I have done so far is this;

VAR PicksTable = GROUPBY(MyTable, [Hour], [Date], [Person], "Value", SUMX(CURRENTGROUP(), IF("Some Criteria"1,0)))

This gives me a neat table like that shown at the top. A column for date, hour, person and value. (My Table has a lot more data in it that I don't need).

What I think I want my Measure to return is something like this;

MAX(PicksTable[Value])

But I cannot do this because I cannot reference the columns in my created (virtual?) table.

I am still learning DAX, but am hoping that by creating a Measure that does this, then creating a Pivot table that has a Row Context of Hour, then I will get the result I need. The Row Context could include person so I would then see which hour is their best hour.

Any help or guidance will be greatly appreciated.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    ChangeType = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Hour", Int64.Type}, {"Person", type text}, {"Value", Int64.Type}}),
    GroupRows = Table.Group(ChangeType, {"Date", "Hour"}, {{"Max", each _, type table [Date=nullable date, Hour=nullable number, Person=nullable text, Value=nullable number]}}),
    GetMax = Table.TransformColumns(GroupRows, {"Max", each List.Max(_[Value])})
in
    GetMax

Book2
ABCDEFGHI
1DateHourPersonValueDateHourMax
24/1/20211Fred74/1/202119
34/1/20211Joe94/1/2021211
44/1/20211Paul54/2/2021213
54/1/20212Fred11
64/1/20212Paul6
74/2/20212Joe13
8
Sheet2
 
Upvote 0

Forum statistics

Threads
1,223,699
Messages
6,173,905
Members
452,536
Latest member
Chiz511

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top