Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
trying to work on some lead times through by obtaining the difference between 2 dates
Committed/Done Diff = IF([DATE1] > [DATE2],"",DATEDIFF([DATE1],[DATE2],DAY))
what i am trying to achieve is have if the date 1 is greater than date 2, then leave field as blank
if date 1 is not greater than date 2, give me the date difference between the 2 dates
the error i get is
"expressions that yield variant data-type cannot be used to define calculated columns"
not sure what i am doing wrong
any help would be appreciated
Solved! Go to Solution.
@Anonymous Reason you're getting this error is because from your IF statement if condition is false then you're returning blank which is of data type text and if true you're returning date. You can't have different data type returns from single IF statement. Therefore if you do conditional column as below it will work.
Committed/Done Diff = IF([DATE1] > [DATE2], today(), DATEDIFF([DATE1],[DATE2],DAY))
@Anonymous Reason you're getting this error is because from your IF statement if condition is false then you're returning blank which is of data type text and if true you're returning date. You can't have different data type returns from single IF statement. Therefore if you do conditional column as below it will work.
Committed/Done Diff = IF([DATE1] > [DATE2], today(), DATEDIFF([DATE1],[DATE2],DAY))
thanks for the reply
that helped but i changed it so i didnt get todays value
Committed/Done Diff = IF([DATE1] > [DATE2], Blank(), DATEDIFF([DATE1],[DATE2],DAY))
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.
| User | Count |
|---|---|
| 48 | |
| 40 | |
| 37 | |
| 20 | |
| 16 |
| User | Count |
|---|---|
| 70 | |
| 67 | |
| 32 | |
| 27 | |
| 25 |