The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello everyone,
So I'm calculationg the difference between two dates that I have. These dates are connected indirectly via table relationship (date 1 is from table 1, date 2 is from table 3, and their connection is that their is a table relationship between table 1- table 2 and table 2 - table 3).
Here is my measure (not a table measure, just a measure):
date 2 - date 1, days =
//Date 2 - Date 1
//DATEDIFF (Date 1, Date 2)
IF(ISBLANK(MAX(date 1) || ISBLANK(MAX(date 2),
BLANK(),
DATEDIFF(MAX(date 1),MAX(date 2),DAY)
)
My goal is when one of the dates has no value, my measure should be blank. Else, subtract the dates.
Below is a screenshot of my table visual without the measure:
I didn't count but maybe there's less than a hundred rows based on the scroll bar.
When I put my measure on the the visual, it goes like this:
The data went huge and the scroll bar became smaller and smaller. It feels like I'm scrolling infinitely.
I'm guessing that there's something wrong with the calculation.. How do I solve this?
Thank you!
Solved! Go to Solution.
@crln-blue That doesn't look like correct syntax at all:
IF( ISBLANK(MAX([date 1])) || ISBLANK(MAX([date 2])),
BLANK(),
DATEDIFF(MAX([date 1]),MAX([date 2]),DAY)
)
Also, you could probably speed things up by doing this:
VAR __MaxDate1 = MAX([date 1])
VAR __MaxDate2 = MAX([date 2])
VAR __Result =
IF( __MaxDate1 = BLANK() || __MaxDate2 = BLANK(),
BLANK(),
(__MaxDate2 - __MaxDate1) * 1.
)
RETURN
__Result
@crln-blue That doesn't look like correct syntax at all:
IF( ISBLANK(MAX([date 1])) || ISBLANK(MAX([date 2])),
BLANK(),
DATEDIFF(MAX([date 1]),MAX([date 2]),DAY)
)
Also, you could probably speed things up by doing this:
VAR __MaxDate1 = MAX([date 1])
VAR __MaxDate2 = MAX([date 2])
VAR __Result =
IF( __MaxDate1 = BLANK() || __MaxDate2 = BLANK(),
BLANK(),
(__MaxDate2 - __MaxDate1) * 1.
)
RETURN
__Result
Thank you, @Greg_Deckler for the help. Your suggestion also helped me troubleshoot and check each fields. Will mark this question as solved. Thanks again!