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.
Hello everyone, I have a bit of an odd one today
I am trying to create a custom column that calculates that date diff between todays date and EITHER the "Ideal Due Date" Column OR the "Fixed Deadline" column, depending on if the column has blanks
So for example in the screenshot BELOW, for Project ID 4 I would want the date diff between Today and the "Ideal Due date" column as the "fixed deadline" column is blank for Project ID 4.
Similar to Project ID 7 I would want the date diff between Today and the "Fixed Deadline" column as the "Ideal Date Column" is blank.
The code I initially had was as follows:
Days until Deadline =
IF (
Table[Ideal Due Date].[Date] = BLANK (),
DATEDIFF ( TODAY (), Table[Fixed Deadline].[Date], DAY ),
IF (
Table[Fixed Deadline].[Date] = BLANK (),
DATEDIFF ( TODAY (), Table[Ideal Due Date].[Date], DAY ),
BLANK ()
)
)
However this code does not seem to work, has anyone got any suggestions? I am thinking I need to utlise a SWITCH function however I am not too sure
A nice to have but not necessarily needed:
Where a Project ID has both values, such as Project ID 1, I want the DateDiff function to prioritise the calculation for the "Fixed Deadline" column.
When a Project ID has neither values, return a "No Deadlines set" text string
Solved! Go to Solution.
Hi,
Try the below solution
Days until Deadline =
-- Returns true if both columns are blank
var CheckBlanks = ISBLANK('Table'[Ideal Due Date]) && ISBLANK('Table'[Fixed Deadline])
-- Returns the difference prioritising Fixed Deadline column
var DaysDiff = int(TODAY() - COALESCE('Table'[Fixed Deadline], 'Table'[Ideal Due Date]))
return if(CheckBlanks, "No Deadlines set", CONVERT(DaysDiff, STRING))
Hi,
Try the below solution
Days until Deadline =
-- Returns true if both columns are blank
var CheckBlanks = ISBLANK('Table'[Ideal Due Date]) && ISBLANK('Table'[Fixed Deadline])
-- Returns the difference prioritising Fixed Deadline column
var DaysDiff = int(TODAY() - COALESCE('Table'[Fixed Deadline], 'Table'[Ideal Due Date]))
return if(CheckBlanks, "No Deadlines set", CONVERT(DaysDiff, STRING))
Thank you! This is exactly what I was after!
And for the nice to have. I would put this in a SWITCH instead of IF because of readability.
Example:
SWITCH(TRUE(),
ISBLANK(Ideal due date) && ISBLANK(Fixed deadline), "No Deadlines set",
NOT ISBLANK(Ideal due date) && NOT ISBLANK(Fixed deadline), INT(TODAY() - Fixed deadline)
)
Implementing this code gives me the following:
Quickfix; dont use DATEDIFF. This returns all dates between given dates, not the arregrate.
Perhapse something like
In this example are you using 'Ideal Due Date' as the table name for the expression 'Ideal Due Date[Fixed Deadline]'?
Should it be INT('Table'[Fixed Deadline] - 'Table'[Start Date]) or 'Ideal Due Date'[Fixed Deadline] intended?
Im returned the following if i use INT('Table'[Fixed Deadline] - 'Table'[Start Date]):
Yeah i just gave examples. I don't have a copy of your data. So you can't copy paste the exact code.
But this is the direction you could go to get your problem fixed.
If you sent a PBIX I can write the exact DAX.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
72 | |
70 | |
37 | |
29 | |
26 |
User | Count |
---|---|
91 | |
49 | |
45 | |
38 | |
37 |