Skip to main content

I'm trying to identify the max month/year for variable Encounter_Date using formula

 

DATETRUNC('month',[Encounter_Date]) = DATETRUNC('month', MAX([Encouter_Date])

 

but it tells me I can't mix aggregate and non-aggregate arguments.

 

Anyone have a better way?

 

Thanks,

 

Brian

5 respuestas
  1. 1 may 2018, 20:05

    Hi Brian

    first to your formula - you have aggregated encounter date with Max therefore other variables would need to be aggregated - but that will not solve the rpoblem

     

    DATETRUNC('month',[Encounter_Date]) = DATETRUNC('month', MAX([Encouter_Date])

     

    what you formula would then do would look at a single record to determine date equaled the max - (once again a single record)

     

    You will need to find the overall max date with something like -           Max date =   {fixed :Max([encounter date])}

     

    now you can use that in your conditional statements like if Datetrunc('month',[encounter date]) = datetrunc('month', [max date]) then ....

     

    depending on what comes next you still may need to aggregate the dates with attr(), min() or max()

     

    Jim

     

    If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

0/9000