PowerPivot- Return The Max Of Column

bravo1563

New Member
Joined
Dec 25, 2013
Messages
20
Hello
Below is sample of my table that I have in a PowerPivot model. What I'm trying to do is return the most recent "Code" associated with the particular "OrderNbr". I need this calculation as a calculated column because I'm going to use this calculated column as a filter. It gets tricky because I have some orders with the same date and unfortunately it's only at a Date level, my data doesn't include a time as well. Can this be done? Any help would be great!

Please note my data isn't sorted like the below, it is sorted randomly.

<colgroup><col><col><col span="2"></colgroup><tbody>
</tbody>
DateOrderNbrValueCode
1/28/201639441$49.00MAN
1/22/201639989$38.00RES
1/28/201648357$48.00MAN
1/21/201650087$28.00MAN
1/23/201650087$49.00MAN
1/27/2016 50087$2.00RES
1/27/201650087$9.00MAN
1/26/201656163$43.00MAN
1/22/201657622$6.00MAN
1/25/201662544$17.00MAN

<colgroup><col><col><col span="2"></colgroup><tbody>
</tbody>
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi bravo1563,

If you want a DAX calculated column, I would use something like this:

=
CALCULATE (
CALCULATE (
// Break ties between Codes on the same date by taking the 'max' Code alphabetically
LASTNONBLANK (
Data
Code:
,[/FONT][/INDENT]
[INDENT=3][FONT=courier new]        0[/FONT][/INDENT]
[INDENT=2][FONT=courier new]    ),[/FONT][/INDENT]
[INDENT=2][FONT=courier new]LASTDATE ( Data[Date] )[/FONT][/INDENT]
[INDENT][FONT=courier new]),[/FONT][/INDENT]
[INDENT][FONT=courier new]ALLEXCEPT ( Data, Data[OrderNbr] )[/FONT][/INDENT]
[FONT=courier new])[/FONT]
 
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,645
Members
448,974
Latest member
DumbFinanceBro

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