Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
UserInterface
Advocate I
Advocate I

Substitute multiple with DirectQuery

How can I substitute text for multiple values?

I tried to nest it as per another post here but I can't do that due to direct query.

 

Custom Status = SUBSTITUTE(SUBSTITUTE('Custom - Requests ++'[Request Status],"On Hold - Pending Customer Feedback","[P] Cust Feedback"),SUBSTITUTE('Custom - Requests ++'[Request Status],"On Hold - Pending 3rd Party Supplier","[P] 3rd Party"),SUBSTITUTE('Custom - Requests ++'[Request Status],"On Hold - Pending Site Visit","[P] Site Visit"),SUBSTITUTE('Custom - Requests ++'[Request Status],	"On Hold - Pending Known Problem","[P] Known Problem"))

Error i get is 'Function 'Substitute is not allowed as part of a calculated column DAX expressions on DirectQuery models'

2 ACCEPTED SOLUTIONS
Seward12533
Solution Sage
Solution Sage

Custom Status =
SUBSTITUTE (
    SUBSTITUTE (
        'Custom - Requests ++'[Request Status],
        "On Hold - Pending Customer Feedback",
        "[P] Cust Feedback"
    ),
    SUBSTITUTE (
        'Custom - Requests ++'[Request Status],
        "On Hold - Pending 3rd Party Supplier",
        "[P] 3rd Party"
    ),
    SUBSTITUTE (
        'Custom - Requests ++'[Request Status],
        "On Hold - Pending Site Visit",
        "[P] Site Visit"
    ),
    SUBSTITUTE (
        'Custom - Requests ++'[Request Status],
        "On Hold - Pending Known Problem",
        "[P] Known Problem"
    )
)

That nested substitute is making my head hurt even after I reformatted it.  If you can do a logical test on a value in your reqeust status column you may be able to use a caluclated column with New Status = SWITCH(TRUE(), test1, restult1, switch2, restult2, ..., elseresult) to build a custom text column. You shoudl be able to use Search, Find for text comparison and any compbination of other test to work out logic ot get what you want. 

 

If you can give us a better idea of what your data looks like and the desired results may be able to help with more specifics. 

View solution in original post

That was exactly what i was after. Thanks..

 

Not sure what happened to formatting on last one. I thought i copied from Notepad++ but maybe i accidently grabbed it from Power BI.. 

Anyway, this was my soultion after using switch like you suggested.

Column = SWITCH(
	'Custom - Requests ++'[Request Status],
	"On Hold","[P]",
	"On Hold - Pending 3rd Party Supplier","[P]3rd Party",
	"On Hold - Pending Known Problem Resolution","[P]Known",
	"On Hold - Pending Site Visit","[P]SSV",
	"On Hold - Pending Customer Feedback","[P]Feedback",
	"None")

View solution in original post

2 REPLIES 2
Seward12533
Solution Sage
Solution Sage

Custom Status =
SUBSTITUTE (
    SUBSTITUTE (
        'Custom - Requests ++'[Request Status],
        "On Hold - Pending Customer Feedback",
        "[P] Cust Feedback"
    ),
    SUBSTITUTE (
        'Custom - Requests ++'[Request Status],
        "On Hold - Pending 3rd Party Supplier",
        "[P] 3rd Party"
    ),
    SUBSTITUTE (
        'Custom - Requests ++'[Request Status],
        "On Hold - Pending Site Visit",
        "[P] Site Visit"
    ),
    SUBSTITUTE (
        'Custom - Requests ++'[Request Status],
        "On Hold - Pending Known Problem",
        "[P] Known Problem"
    )
)

That nested substitute is making my head hurt even after I reformatted it.  If you can do a logical test on a value in your reqeust status column you may be able to use a caluclated column with New Status = SWITCH(TRUE(), test1, restult1, switch2, restult2, ..., elseresult) to build a custom text column. You shoudl be able to use Search, Find for text comparison and any compbination of other test to work out logic ot get what you want. 

 

If you can give us a better idea of what your data looks like and the desired results may be able to help with more specifics. 

That was exactly what i was after. Thanks..

 

Not sure what happened to formatting on last one. I thought i copied from Notepad++ but maybe i accidently grabbed it from Power BI.. 

Anyway, this was my soultion after using switch like you suggested.

Column = SWITCH(
	'Custom - Requests ++'[Request Status],
	"On Hold","[P]",
	"On Hold - Pending 3rd Party Supplier","[P]3rd Party",
	"On Hold - Pending Known Problem Resolution","[P]Known",
	"On Hold - Pending Site Visit","[P]SSV",
	"On Hold - Pending Customer Feedback","[P]Feedback",
	"None")

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.