Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

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

     

    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.

6 Replies

  • 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's avatar
      Anonymous
      Not applicable

      Hi 

       

       

       

       

       

      • v-easonf-msft's avatar
        v-easonf-msft
        Icon for Community Support rankCommunity 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"
                )
            )
        )

         

        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.

  • az38's avatar
    az38
    Icon for Community Champion rankCommunity 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")

     

    • Anonymous's avatar
      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!