Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

DATEADD

 

I am using a meausre to create a vertical line at a certain point

This DAX creates the line succesfully

referenceline =

IF(
    MAX('FACT SALES'[Date]) = DATE(2020,5,1),
    20000, // height of the line
    BLANK()
)

 

If I Replace the DATE(2020.5.1) With ANY expression using DateAdd, LastDate,  COnvert    etc  it will fail to produce the line

But When I use it as an expression it fails

Referenceline =


IF(
    MAX('FACT SALES'[Date]) = DATE(YEAR(MAX('FACT SALES'[Date])), MONTH(MAX('FACT SALES'[Date]))-1, DAY(MAX('FACT SALES'[Date]))),
    20000, // height of the line
    BLANK()
)
 
This also fails
MAX('FACT SALES'[Date]) = DATEADD(LASTDATE('FACT SALES'[Date]), -30,DAY) , //THIS DOESNT WHY??
200, // height of the line
BLANK()
 
why is it only the literal DATE(2020,4,30) that will work

 

2 REPLIES 2
az38
Community Champion
Community Champion

@Anonymous 

pay attention for remark in DATEADD() documentation here https://docs.microsoft.com/en-us/dax/dateadd-function-dax

The result table includes only dates that exist in the dates column.

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
harshnathani
Community Champion
Community Champion

@Anonymous 

 

You can use the below measures.

 

 

Max Date = MAX(Supplier[Date])

 

MAX Date1 =

var _mm = MONTH([Max Date])
var _dd = DAY([Max Date])
var _year = YEAR([Max Date])
return
IF ([Max Date] = DATE(_year,_mm,_dd), 5000, Blank())
 
 
You are comparing the max date by breaking the year, months and date of max date in parts. But why have you reduced the month by 1.
 
This will obviously not match the MAX Date for Sales.
 
123.JPG
 
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.