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

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

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.