Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

The MAX function in DAX only accepts a column reference as an argument

Hi All,

I am new to DAX. Below is my code:

var maxdate = MAX((DATEADD(DimDate[Date], -1 , month)))

From research, DATEADD returns A table containing a single column of date values.

 

However, I get the following error when I try to save the measure "The MAX function only accepts a column reference as an argument."  What is the name of the column in the table return by DATEADD so I can reference it?

  • Hello Anonymous 

    Instead of MAX try it with LASTDATE, should give you what you are looking for.

    VAR maxdate = LASTDATE ( DATEADD ( DimDate[Date],-1, MONTH ) )

3 Replies

  • Hello Anonymous 

    Instead of MAX try it with LASTDATE, should give you what you are looking for.

    VAR maxdate = LASTDATE ( DATEADD ( DimDate[Date],-1, MONTH ) )
  • The above solution or you can try

     maxx('DimDate',DATEDIFF('DimDate'[Date],-1,MONTH))