Power pivot formula - find max price with conditions

DallDenmark

New Member
Joined
May 3, 2018
Messages
5
I have a data set where below is an example.

I need to find the price with the latest start data, filtered by project no, task code and code.

So for Project no 032839-003 for code "E2" and task code "blank", the correct price is 725 since the latest start data is 01-01-2016.

[TABLE="width: 628"]
<tbody>[TR]
[TD]Project No_[/TD]
[TD]Task Code[/TD]
[TD]Work Type Code[/TD]
[TD]Code[/TD]
[TD]Start Date[/TD]
[TD]Price[/TD]
[/TR]
[TR]
[TD]032839-003[/TD]
[TD][/TD]
[TD]SH[/TD]
[TD]E2[/TD]
[TD]01-01-2015[/TD]
[TD]720[/TD]
[/TR]
[TR]
[TD]040238-001[/TD]
[TD][/TD]
[TD]SH[/TD]
[TD]E2[/TD]
[TD]01-01-2015[/TD]
[TD]720[/TD]
[/TR]
[TR]
[TD]032839-003[/TD]
[TD][/TD]
[TD]SH[/TD]
[TD]E2[/TD]
[TD]01-01-2016[/TD]
[TD]725[/TD]
[/TR]
[TR]
[TD]040238-001[/TD]
[TD][/TD]
[TD]SH[/TD]
[TD]E2[/TD]
[TD]01-01-2016[/TD]
[TD]725[/TD]
[/TR]
[TR]
[TD]032839-003[/TD]
[TD]30.17.1000[/TD]
[TD]SH[/TD]
[TD]E2[/TD]
[TD]01-01-2016[/TD]
[TD]725[/TD]
[/TR]
[TR]
[TD]040238-001[/TD]
[TD]30.17.1000[/TD]
[TD]SH[/TD]
[TD]E2[/TD]
[TD]01-01-2016[/TD]
[TD]725[/TD]
[/TR]
[TR]
[TD]032839-003[/TD]
[TD]10.07.1000[/TD]
[TD]SH[/TD]
[TD]E2[/TD]
[TD]01-01-2016[/TD]
[TD]825[/TD]
[/TR]
[TR]
[TD]040238-001[/TD]
[TD]10.07.1000[/TD]
[TD]SH[/TD]
[TD]E2[/TD]
[TD]01-01-2016[/TD]
[TD]825[/TD]
[/TR]
[TR]
[TD]032839-003[/TD]
[TD]10.07.1000[/TD]
[TD]SH[/TD]
[TD]E2[/TD]
[TD]01-01-2015[/TD]
[TD]815[/TD]
[/TR]
[TR]
[TD]040238-001[/TD]
[TD]10.07.1000[/TD]
[TD]SH[/TD]
[TD]E2[/TD]
[TD]01-01-2015[/TD]
[TD]815[/TD]
[/TR]
[TR]
[TD]032839-003[/TD]
[TD]30.17.1000[/TD]
[TD]SH[/TD]
[TD]E2[/TD]
[TD]01-01-2015[/TD]
[TD]815[/TD]
[/TR]
[TR]
[TD]040238-001[/TD]
[TD]30.17.1000[/TD]
[TD]SH[/TD]
[TD]E2[/TD]
[TD]01-01-2015[/TD]
[TD]815[/TD]
[/TR]
</tbody><colgroup><col><col><col><col><col><col></colgroup>[/TABLE]

How do I make a formula in Powerpivot, giving me this result?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
What version of Excel are you using? Are you looking for a measure or calculated column?
 
Upvote 0
Try this (with your own table name of course).
-- I used xCode for the last parameter so it wouldn't conflict with the HTML
Code:
 tag --

[CODE]Latest Price =
CALCULATE (
    MAX ( Price ),
    FILTER (
        tablename,
        MAX ( tablename[Start Date] ) = tablename[Start Date]
            && tablename[Project No_] = EARLIER ( tablename[Project No_] )
            && tablename[Task Code] = EARLIER ( tablename[Task Code] )
            && tablename[xCode] = EARLIER ( tablename[xCode] )
    )
)
 
Last edited:
Upvote 0
The formula works when I copy the data to a table and uses this. Any idea why the formula does not work on data imported through Power query? Some kind of formatting?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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