2

I'm trying to add days in the date field but I always have the same error, my field "event_date" is date. I don't know what's wrong

Error

enter image description here

userActive =
var datamaxx = CONVERT (CALCULATE (max (table1 [event_date])), DATETIME)
var dad = DATEADD (DATE (YEAR (datamaxx), MONTH (datamaxx), DAY ((datamaxx))), 1, DAY)

or

userActive =
var datamaxx = CONVERT (CALCULATE (max (table1 [event_date])), DATETIME)
var dad = DATEADD (datamaxx, 1, DAY)

2 Answers 2

0

Are you trying to create a measure or a calculated column?

I simplified the below by removing the CALCULATE and also adding in the RETURN statement, you must RETURN a value when you have a multi-statement DAX formula.

Note DATEADD returns a column of dates.

userActive = 
var datamaxx = TODAY()
RETURN DATE(YEAR(datamaxx), MONTH(datamaxx), DAY(datamaxx) + 1)
3
  • I try create the CALCULATE, I did that commented but the error remains in the variable (datamaxx) "Parameter is not correct type" Sep 24, 2020 at 18:38
  • I tried to use today () but even so, error userActive = var datamaxx = TODAY () return DATEADD (datamaxx, 1, DAY) Sep 24, 2020 at 18:47
  • See my edit to my answer. I have tested an it works. Sep 24, 2020 at 19:08
0

You said your event_date column is a date. Not sure why you are trying to CONVERT it to DATETIME again! This is going to just add 00:00:00 to the time part in the column.

Second, why your are dividing the DateTime value into YEAR, MONTH & DATE to create a DATE value where as the variable already holding value of DATETIME type?

Now, if your only intension is to add 1 day with the current date value and wants to store the value in a new Measure, you can create this below measure simply-

date+1 = max (table1[event_date]) + 1

This +1 will increase your date value by 1 day. This will work as you said your source column's data type is date.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.