This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hi all,
I am trying to create a calculated column where in if date is equal to "2019/11/24" then print Static otherwise the date value. I am using the below two logic but keep getting an error - "Expression that yield variant date-type cannot be used to define calculated column"
The date column is of type "Date/time" with format "dd-mm-yyyy hh:min:sec(G)" - Please help
Column = If(Table1[date] = Date(2019,11,24),"Static",Table1[date])
Column = If(Table[date] = DateValue("2019-11-24"),"Static",Table1[date])
Thanks,
Vikash
Solved! Go to Solution.
Try like
Column = If(Table1[date] = Date(2019,11,24),"Static",format(Table1[date],"dd-mm-yyyy hh:mi:ss"))
for full set of options refer
https://docs.microsoft.com/en-us/dax/custom-date-and-time-formats-for-the-format-function
Hi @Anonymous ,
This error is reported because your calculated column returned two types of data: text & date.
So, you can refer to @amitchandak 's answer.
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Try like
Column = If(Table1[date] = Date(2019,11,24),"Static",format(Table1[date],"dd-mm-yyyy hh:mi:ss"))
for full set of options refer
https://docs.microsoft.com/en-us/dax/custom-date-and-time-formats-for-the-format-function
Thanks very much @amitchandak , It worked. I now understand that the return type has to be same datatype.
Go into Power Query (Transform Data button on home ribbon) and verify that is truly a date column. I bet it shows ABC/123 as the column data type. Click that and change it to date, or date/time.
Just because visually it looks like a date doesn't mean Power BI will see it as a date. It must actually be the Date data type.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingCheck out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 27 | |
| 25 | |
| 22 | |
| 20 | |
| 14 |
| User | Count |
|---|---|
| 50 | |
| 47 | |
| 23 | |
| 18 | |
| 18 |