Creating a MAXIF in DAX

ExcelWhizzDotCom

New Member
Joined
Dec 31, 2015
Messages
11
Hi guys,

I'm really struggling to get this to filter as I wish using CALCULATE. Can anyone help with correct DAX, or offer any alternative methods of achieving this in Power Pivot?

The relevant fields in my dataset are: SiteID, AssessmentDate, Grade. I only want my model to to filter for the last graded assessment at each site.

Therefore I'm trying to create a column flagging the max AssessmentDate for each SiteID but only where [Grade]<>"Ungraded".

Any advice would be gratefully received!

Regards
EW
 

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.
I'm not clear on your final result - are you looking for the grade given for the latest not-ungraded assessment date? If all you want is to put the last relevant assessment date into every row of the table you can try as a new column formula
Code:
NewColumn=CALCULATE (
    MAX ( [AssessmentDate] ),
    FILTER (
        ALL ( YourTableName ),
        [SiteID] = EARLIER ( [SiteID] )
            && [Grade] <> "Ungraded"
    )
)

If you want the grade associated with that last assessment date for the site then you'd need a VALUES to pull the grade, assuming that only one grade is associated with each assessment date per site ID. That could be a measure rather than a column but you'd need to provide more info.
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

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