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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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