Forum Discussion
Calculated Column
Hello - I need help in creating a calculated column to return:-
If Purchase Order = “Email” or “TBA” or “TBC” and Reason is “Blank” Return “Pending PO”
If Purchase Order has one digit value and Reason is “Blank” Return “Upload in Progress”
If Purchase Order has one digit value and Reason is “Uploaded” Return “Uploaded”
If Purchase Order has a “Value starting with DW” Return “Uploaded”
else
Return "Error"
(Data) Excel file Link - Click Here
| PurchaseOrder | Reason |
| 1063138/1064662 | Uploaded |
| 1063507/1063393 | |
| 8007215/8006322 | Uploaded |
| 8006386/8007591 | Uploaded |
| TBA | |
| TBA | Uploaded |
| 1064132/1064116 | Uploaded |
| 8006465/8006468/8006467 | |
| 1063507/1063393/80064876 | Uploaded |
| TBA | Uploaded |
| TBC | |
| 1063138 | Uploaded |
| 1064662 | |
| Uploaded |
Result
| PurchaseOrder | Reason | Status (Result) |
| 1063138/1064662 | Uploaded | Uploaded |
| 1063507/1063393 | Upload in Progress | |
| 8007215/8006322 | Uploaded | Uploaded |
| 8006386/8007591 | Uploaded | Uploaded |
| TBA | Pending PO | |
| TBA | Uploaded | Error |
| 1064132/1064116 | Uploaded | Uploaded |
| 8006465/8006468/8006467 | Upload in Progress | |
| 1063507/1063393/80064876 | Uploaded | Uploaded |
| TBA | Uploaded | Error |
| TBC | Pending PO | |
| 1063138 | Uploaded | Uploaded |
| 1064662 | Upload in Progress | |
| Pending PO | ||
| Uploaded | Error |
gauravnarchal add a new column using following DAX and it will do it, you can always tweak it as you see fit:
Status = VAR __PO = PO[PurchaseOrder] VAR __Reason = COALESCE ( PO[Reason], "" ) VAR __isNumber = NOT ( IFERROR ( VALUE ( SUBSTITUTE ( PO[PurchaseOrder], "/", "" ) ), BLANK() ) == BLANK() ) RETURN SWITCH ( TRUE(), __PO IN { "Email", "TBA", "TBC" } && __Reason = "", "Pending PO", __isNumber && __Reason = "", "Uploaded in Progress", ( __isNumber && __Reason = "Uploaded") || ( LEFT ( __PO, 2 ) = "DW" ), "Uploaded", "Error" )✨ Follow us on LinkedIn
Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
4 Replies
- parry2kSuper User
gauravnarchal add a new column using following DAX and it will do it, you can always tweak it as you see fit:
Status = VAR __PO = PO[PurchaseOrder] VAR __Reason = COALESCE ( PO[Reason], "" ) VAR __isNumber = NOT ( IFERROR ( VALUE ( SUBSTITUTE ( PO[PurchaseOrder], "/", "" ) ), BLANK() ) == BLANK() ) RETURN SWITCH ( TRUE(), __PO IN { "Email", "TBA", "TBC" } && __Reason = "", "Pending PO", __isNumber && __Reason = "", "Uploaded in Progress", ( __isNumber && __Reason = "Uploaded") || ( LEFT ( __PO, 2 ) = "DW" ), "Uploaded", "Error" )✨ Follow us on LinkedIn
Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
- parry2kSuper User
gauravnarchal what you mean by this condition, can you clarify:
If Purchase Order has one digit value
- gauravnarchalPost Prodigy
Hi parry2k - I mean all values in purchase order should be digits except "/" slash.
For eg:- 1063138/1064662 or 1063507/1063393/80064876 or 1063138
- Ashish_MathurSuper User
Hi,
I think i can solve this using Power Query. Would you be OK with a Power Query solution?