Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi, im a new user in Power BI. Currently my task is to calculate the time difference between two dates, A and B, where supposed Date B is later than Date A. Since there are some technical error where Date A is later than Date B, it produces a negative result. Thus, now I need to do an IF to check if the Date A is later than Date B, return null, else run the calculation. But power BI is giving me an error.
Unless, I didn't run the calculation, and I return string type, then it would work fine. And please let me know if I declare null correctly.
Can anybody give some tips on the solution?
Solved! Go to Solution.
IF you are creating the measure then use following DAX :
IF you are creating the measure then use following DAX :
Yes, I've tried like this before. But I had wrongly set the sequence and I didn't set the variable. Maybe that's why it run into error. But my solution is the same as this one, so I will mark this as a solution. Thanks!
I haven't looked at the logic of the calculation. I'm just trying to get you past the error. Replace "null" with blank()
You have to return the same datatype from all paths of the 'if' statement. At the moment a string or a number are being returned. Try blank()
But how to show the result of DATEDIFF calculation if I put blank() ?
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
12 | |
10 | |
6 |