Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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!

3 ACCEPTED SOLUTIONS
amitchandak
Super User
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")

View solution in original post

az38
Community Champion
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")

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

Hi, @Anonymous 

Is  this your expected result ?

19.png

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"
        )
    )
)

 

pbix attached

 

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.

View solution in original post

6 REPLIES 6
az38
Community Champion
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")

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

Hi 

 

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!

 

 

amitchandak
Super User
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")
Anonymous
Not applicable

Hi 

 

 

 

 

 

Hi, @Anonymous 

Is  this your expected result ?

19.png

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"
        )
    )
)

 

pbix attached

 

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.

Anonymous
Not applicable

Hi @v-easonf-msft Thanks for your reply. That is exactly what I need. I've just replicate your formula in my pbix and... is working! You don't know how happy I am right now! Thank you so so much for your help!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.