How can I calculate the MIN using specific criteria?

Think outside the DAX MAX SHAX box

declare @sql4 table(ID char(1), sql4Date date, conditional char(1))

insert into @sql4
select 'A', '2020-01-01', 'Y' union all
select 'A', '2020-02-01', 'Y' union all
select 'A', '2020-03-01', 'Y' union all
select 'B', '2020-04-01', 'Y' union all
select 'B', '2020-05-01', 'Y' 


;with sqlfor
as
(
select * , 
       ROW_NUMBER() OVER(PARTITION BY ID ORDER BY sql4Date ASC)  as _row
  From @sql4
)
select  *
  from sqlfor
  where _row = 1
    and sql4Date > '02/01/2020'

@sqlor

you've asked a lot of questions on here and we are happy to help, but the underlying issue to all your questions is to provide usable DDL and sample data. Pictures do not help and us creating it for you is a best guess at what you are asking. If you look at all the responses in this thread, they show working DDL and sample data. I don't want to discourage you from asking questions, I want to request that you provide the same when you ask. It will help us and prevent a lot of back and forth.

3 Likes

I showed you a solution using row_number() - which you obviously have not tried. Please try using the sample code that was provided.

You may think your statement is very neat - but to me it means absolutely nothing. I have no idea what that statement is doing or how it works and would have to dig through documentation to figure it out. Just because it is something you are familiar with doesn't mean it is easy for someone not familiar with that language.