Forum Discussion
FarmerKenny
Helper II
4 years agoRetrieve rows for max date and 2nd to max date
I have a filter that retrieves the correct set of rows for the most recent date in a table: Occupation Summary = FILTER ( FILTER ( 'SitStat', 'SitStat'[MetricName] = "Occupation Summary"...
- 4 years ago
Hi FarmerKenny
Try this:
Occupation Summary = VAR _A = FILTER( 'SitStat', 'SitStat'[MetricName] = "Occupation Summary" ) VAR _1D = CALCULATE( MAX( 'SitStat'[create_dt] ), FILTER( 'SitStat', 'SitStat'[MetricName] = "Occupation Summary" ) ) VAR _2D = CALCULATE( MAX( 'SitStat'[create_dt] ), FILTER( ALL( 'SitStat' ), 'SitStat'[MetricName] = "Occupation Summary" && 'SitStat'[create_dt] < _1D ) ) RETURN FILTER( _A, 'SitStat'[create_dt] = _1D || 'SitStat'[create_dt] = _2D )If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/ - 4 years ago
I worked on this over the weekend, and since DAX is new to me, I wrote it in T-SQL. (Perhaps MS should support a SQL to DAX conversion utility...)
Actual Solution
FarmerKenny
Helper II
4 years agoThanks, I know that coding with out a database to access is tough. I appreciate your attempts, and I will post the successful code here when I get this to work.
FarmerKenny
Helper II
4 years agoI worked on this over the weekend, and since DAX is new to me, I wrote it in T-SQL. (Perhaps MS should support a SQL to DAX conversion utility...)
Actual Solution