Forum Discussion
Expressions that yield variant data-type cannot be used to define calculated columns
Dear Community,
I have the below formula that is returning the above error - please can you help me?
I'm trying to achieve a column that defines the status of a milestone based on dates. I already created previous formulas that were not working, but I did not get this error. And I am not mixing number and text values, so I can't figure out why is not working. Can you please help me?
Basically I want to define the status of the response milestone, based on the dates (response date, and target date). However and because I have multiple conditions I found easier to use the switch function:
Response Status =
SWITCH(TRUE(),
'main table'[Response Date]< 'main table'[Response_Target_Date], "Succeeded",
'main table'[Response Date]> 'main table'[Response_Target_Date], AND(OR(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date]<TODAY()),"Noncompliant"),
AND(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date]>TODAY()),"Response not sent",
"NA")
Thank You!
Anonymous , Try like
Response Status = SWITCH(TRUE(), 'main table'[Response Date]< 'main table'[Response_Target_Date], "Succeeded", AND('main table'[Response Date]> 'main table'[Response_Target_Date], OR(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date]<TODAY())),"Noncompliant", AND(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date]>TODAY()),"Response not sent", "NA")Anonymous hi
the problem is somewhere in this part
'main table'[Response Date]> 'main table'[Response_Target_Date], AND(OR(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date]<TODAY()),"Noncompliant"), AND(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date]>TODAY()),"Response not sent",I was not able to understand the logic, but I can suppose that you have an incorrect first AND
try
Response Status = SWITCH(TRUE(), 'main table'[Response Date] < 'main table'[Response_Target_Date], "Succeeded", 'main table'[Response Date] > 'main table'[Response_Target_Date] && (OR(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date] < TODAY()), "Noncompliant", AND(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date] > TODAY()), "Response not sent", "NA")Hi, Anonymous
Is this your expected result ?
Try calculated column as below:
Response Status = IF ( ISBLANK ( 'main table'[Response_Target_Date] ), "N/A", IF ( ISBLANK ( 'main table'[Response Date] ) && 'main table'[Response_Target_Date] > TODAY (), "Response not send", IF ( 'main table'[Response Date] <> BLANK () && 'main table'[Response Date] <= TODAY () && 'main table'[Response Date] < 'main table'[Response_Target_Date], "Succeeded", "Noncompliant" ) ) )Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
6 Replies
- amitchandak
Super User
Anonymous , Try like
Response Status = SWITCH(TRUE(), 'main table'[Response Date]< 'main table'[Response_Target_Date], "Succeeded", AND('main table'[Response Date]> 'main table'[Response_Target_Date], OR(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date]<TODAY())),"Noncompliant", AND(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date]>TODAY()),"Response not sent", "NA")- AnonymousNot applicable
Hi amitchandak,
Thanx for answering so quick!
The issue is now solved. However the formula is not retrieving the correct status:
AND(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date]>TODAY()),"Response not sent"
I am getting the "Succeeded" status with the Response Date in blank and the Target Date < Today.
And if the Target Date is missing it is appearing as " NA", even if the Response Date is blank.
Also if I have a Response Date, but not a Target Date it is appearing as "Noncompliant", which souldn't because if it does not have a target date.
I am realizing that I have a lot of conflicting conditions, and not sure how to proceed further with this.
Thanks for your help!
- v-easonf-msft
Community Support
Hi, Anonymous
Is this your expected result ?
Try calculated column as below:
Response Status = IF ( ISBLANK ( 'main table'[Response_Target_Date] ), "N/A", IF ( ISBLANK ( 'main table'[Response Date] ) && 'main table'[Response_Target_Date] > TODAY (), "Response not send", IF ( 'main table'[Response Date] <> BLANK () && 'main table'[Response Date] <= TODAY () && 'main table'[Response Date] < 'main table'[Response_Target_Date], "Succeeded", "Noncompliant" ) ) )Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- az38
Community Champion
Anonymous hi
the problem is somewhere in this part
'main table'[Response Date]> 'main table'[Response_Target_Date], AND(OR(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date]<TODAY()),"Noncompliant"), AND(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date]>TODAY()),"Response not sent",I was not able to understand the logic, but I can suppose that you have an incorrect first AND
try
Response Status = SWITCH(TRUE(), 'main table'[Response Date] < 'main table'[Response_Target_Date], "Succeeded", 'main table'[Response Date] > 'main table'[Response_Target_Date] && (OR(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date] < TODAY()), "Noncompliant", AND(ISBLANK('main table'[Response Date]),'main table'[Response_Target_Date] > TODAY()), "Response not sent", "NA")- AnonymousNot applicable
Hi az38,
Thanks you for your quick answer. The formula is not giving any error now.
However I have a problem with the Status. As you can see in the reply to amitchandak. Maybe you can help as well.
I am stuck and cannot move further with this.
Thank you!