Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Solved! Go to Solution.
Hi @nguyenk172 ,
The formula you are using needs to be split and cannot be equal to one data and then directly equal to another value.
Refer the following sample ,as you provided:
Type1 =
SWITCH (
TRUE (),
ISBLANK ( PurchaseOrders[Agreement_KONNR] )
&& PurchaseOrders[CreatedBy_ERNAM] = "BATCHJOB",
"UC4BATCH"
&& PurchaseOrders[DocumentType_BSART] = "ZB",
"Z1", "SPA",
"Spot PO"
)
Get:
And after adjust:
Type =
SWITCH (
TRUE (),
ISBLANK ( PurchaseOrders[Agreement_KONNR] )
&& ( PurchaseOrders[CreatedBy_ERNAM] = "BATCHJOB"
|| PurchaseOrders[CreatedBy_ERNAM] = "UC4BATCH" )
&& ( PurchaseOrders[DocumentType_BSART] = "ZB"
|| PurchaseOrders[DocumentType_BSART] = "Z1" ), "SPA",
"Spot PO"
)
Output:
And according your provided data,you need to adjust to the below:
Type1 =
SWITCH (
TRUE (),
ISBLANK ( PurchaseOrders[Agreement_KONNR] )
&& (PurchaseOrders[CreatedBy_ERNAM] = "BATCHJOB"||PurchaseOrders[CreatedBy_ERNAM] = "UC4BATCH"
)
&& (PurchaseOrders[DocumentType_BSART] = "ZB"||PurchaseOrders[DocumentType_BSART]= "Z1")
, "SPA",
NOT ISBLANK ( PurchaseOrders[Agreement_KONNR] )
&& (PurchaseOrders[CreatedBy_ERNAM] = "BATCHJOB"||PurchaseOrders[CreatedBy_ERNAM] = "UC4BATCH"),
"Auto Calloff",
NOT ISBLANK ( PurchaseOrders[Agreement_KONNR] )
&& (NOT PurchaseOrders[CreatedBy_ERNAM] = "BATCHJOB"||NOT PurchaseOrders[CreatedBy_ERNAM] = "UC4BATCH"),
"Buyer Intervention",
"Spot PO"
)
Did I answer your question? Mark my post as a solution!
Best Regards
Lucien
Hi @nguyenk172 ,
The formula you are using needs to be split and cannot be equal to one data and then directly equal to another value.
Refer the following sample ,as you provided:
Type1 =
SWITCH (
TRUE (),
ISBLANK ( PurchaseOrders[Agreement_KONNR] )
&& PurchaseOrders[CreatedBy_ERNAM] = "BATCHJOB",
"UC4BATCH"
&& PurchaseOrders[DocumentType_BSART] = "ZB",
"Z1", "SPA",
"Spot PO"
)
Get:
And after adjust:
Type =
SWITCH (
TRUE (),
ISBLANK ( PurchaseOrders[Agreement_KONNR] )
&& ( PurchaseOrders[CreatedBy_ERNAM] = "BATCHJOB"
|| PurchaseOrders[CreatedBy_ERNAM] = "UC4BATCH" )
&& ( PurchaseOrders[DocumentType_BSART] = "ZB"
|| PurchaseOrders[DocumentType_BSART] = "Z1" ), "SPA",
"Spot PO"
)
Output:
And according your provided data,you need to adjust to the below:
Type1 =
SWITCH (
TRUE (),
ISBLANK ( PurchaseOrders[Agreement_KONNR] )
&& (PurchaseOrders[CreatedBy_ERNAM] = "BATCHJOB"||PurchaseOrders[CreatedBy_ERNAM] = "UC4BATCH"
)
&& (PurchaseOrders[DocumentType_BSART] = "ZB"||PurchaseOrders[DocumentType_BSART]= "Z1")
, "SPA",
NOT ISBLANK ( PurchaseOrders[Agreement_KONNR] )
&& (PurchaseOrders[CreatedBy_ERNAM] = "BATCHJOB"||PurchaseOrders[CreatedBy_ERNAM] = "UC4BATCH"),
"Auto Calloff",
NOT ISBLANK ( PurchaseOrders[Agreement_KONNR] )
&& (NOT PurchaseOrders[CreatedBy_ERNAM] = "BATCHJOB"||NOT PurchaseOrders[CreatedBy_ERNAM] = "UC4BATCH"),
"Buyer Intervention",
"Spot PO"
)
Did I answer your question? Mark my post as a solution!
Best Regards
Lucien
Hi,
Found your question interesting and I came up with the following. Hope it helps and at the very least, points you to the right direction to get your formula working.
Assign Status =
VAR _checkAgreement = IF ( MAX ( Purchases[AgreementID] ) = "-", TRUE(),FALSE())
VAR _checkCreated = OR ( MAX (Purchases[CreatedBy])="BATCHJOB", MAX(Purchases[CreatedBy])="UC4BATCH")
VAR _checkDocType = OR ( MAX (Purchases[DocumentType])="Z1", MAX(Purchases[DocumentType])="ZB")
VAR _status =
SWITCH(TRUE(),
_checkAgreement && _checkCreated && _checkDocType, "SPA",
_checkAgreement = FALSE() && _checkCreated, "Auto Calloff",
_checkAgreement = FALSE() && _checkCreated = FALSE(),"Buyer Intervention",
"Spot PO"
)
RETURN
_status
Link to example PBIX for reference - SWITCH example
I had some trouble with the ISBLANK() function so I substituted "-" into the data as a check to save time.
Example table and results to check logic:-
Hi @nguyenk172 ,
Looks some issue in switch conditions, Could you please share the sample data in text format with expected output?
Thanks,
Samarth
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 43 | |
| 39 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 63 | |
| 32 | |
| 30 | |
| 23 |