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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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