Forum Discussion

TylerVono's avatar
TylerVono
Helper III
3 years ago

Boolean IF Statements - Need Help

Hello I am trying to do a nested IF statement but keep arriving on an error:

Here is the equation:

 

PO Status = if(AND('PO Data'[Closed for Receipt Date]>'PO Data'[First Promised Date],'PO Data'[BooleanMeasureClosedCode] = "CLOSED"||"CLOSED FOR INVOICE"||"CLOSED FOR RECEIVING"||"FINALLY CLOSED"),"Delivered Late", if(and('PO Data'[First Promised Date]<today(),isblank('PO Data'[Closed for Receipt Date])&& 'PO Data'[PO Status]="OPEN"),"Currently Past Due","")
 
BooleanMeasureClosedCode = if('PO Data'[Closed Code] = "CLOSED" || "CLOSED FOR INVOICE" || "CLOSED FOR RECEIVING",TRUE(),FALSE())
 
My Data Type is True/False.
 
My Column: [Closed Code] just tells three options: CLOSED,CLOSED FOR INVOICE, CLOSED FOR RECEIVING AND OPEN.
 
What am I doing wrong?

5 Replies

  • mlsx4's avatar
    mlsx4
    Memorable Member

    Hi TylerVono 

     

    You are trying to compare the result of BooleanMeasureClosedCode which will be True or False with text here:

     

    BooleanMeasureClosedCode = if('PO Data'[Closed Code] = "CLOSED" || "CLOSED FOR INVOICE" || "CLOSED FOR RECEIVING",TRUE(),FALSE())

     

    PO Data'[BooleanMeasureClosedCode] = "CLOSED"||"CLOSED FOR INVOICE"||"CLOSED FOR RECEIVING"||"FINALLY CLOSED")

     

    I mean the part is green is what you get and the part in red what you are trying to compare... Then True() or False() will never be "Closed" or something like this.

  • Hello mlsx4 , I dont understand....what should be the correct way to write the measure? I basically just want the measure to say if any of those closed options are present and the Receipt Date is later than the Promised Date, then its 'Delivered Late".

     

    = if(AND('PO Data'[Closed for Receipt Date]>'PO Data'[First Promised Date],'PO Data'[BooleanMeasureClosedCode] = "CLOSED"||"CLOSED FOR INVOICE"||"CLOSED FOR RECEIVING"||"FINALLY CLOSED"),"Delivered Late"," "))
    • mlsx4's avatar
      mlsx4
      Memorable Member

      The thing is that at the end you are trying to compare a text with a true/false value.

      Imagine you have this data:

       

      Closed dateClosed Code
      19/07/2023Closed for receiving

       

      What you have written will do:

      BooleanMeasureClosedCode= TRUE -> Because it is closed for receiving.

       

      And now when you go to PO status, it will try to do: 

       if(AND('PO Data'[Closed for Receipt Date]>'PO Data'[First Promised Date]TRUE = "CLOSED"||"CLOSED FOR INVOICE"||"CLOSED FOR RECEIVING"||"FINALLY CLOSED"),

       

      Do you see what I'm trying to explain? That now you are trying that True = to one of the status...Therefore, it doesn't make any sense.

       

       

      You don't need the measure which returns true.... You have to directly do:

       

       

       

      PO Status = if(AND('PO Data'[Closed for Receipt Date]>'PO Data'[First Promised Date],'PO Data'[ClosedCode] = "CLOSED"||"CLOSED FOR INVOICE"||"CLOSED FOR RECEIVING"||"FINALLY CLOSED"),"Delivered Late", if(and('PO Data'[First Promised Date]<today(),isblank('PO Data'[Closed for Receipt Date])&& 'PO Data'[PO Status]="OPEN"),"Currently Past Due","")

       

      Or if you want to use the measure, just check if PO Data'[BooleanMeasureClosedCode] = true or false (as needed)

       

       Btw, I don't know if it works since I don't have any kind of data or structure.

      • TylerVono's avatar
        TylerVono
        Helper III

        Oh yes I see, I think I was over-complicating it.... so now I have a different error: