The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello I am trying to do a nested IF statement but keep arriving on an error:
Here is the equation:
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".
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 date | Closed Code |
19/07/2023 | Closed 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.
Oh yes I see, I think I was over-complicating it.... so now I have a different error:
Now, I cannot figure out what is happening 😅
My advice is that you try to check the code step by step. For instance, check if the first condition is working:
PO Status = if('PO Data'[Closed for Receipt Date]>'PO Data'[First Promised Date],1,0)
If it is, try to add another piece of code:
PO Status = if(AND('PO Data'[Closed for Receipt Date]>'PO Data'[First Promised Date],'PO Data'[ClosedCode]= "CLOSED"),1,0)
And so on...
Anyway, if you provide a piece of data with the structure of what you are trying to calculate, I could help you
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.
User | Count |
---|---|
74 | |
70 | |
39 | |
30 | |
28 |
User | Count |
---|---|
104 | |
95 | |
51 | |
48 | |
46 |