Forum Discussion
Alternative syntax to CONTAINSSTRING using Direct Connect to SSAS
What alternative DAX syntax can I use to CONTAINSSTRING when connecting to a tabular model using SSAS?
I want to define a measure that counts the number of accounts containing a specific string. I'm new to DAX, so forgive me if this is wrong, but something like this is what I wanted to do:
Hi cklopper ,
Sorry for replying late. Plese check the SSAS version you are running as the CONTAINSSTRING function only works from >= SSAS 2019 CTP2.3.
You can refer this simliar issue:
Best Regards,
Yingjie LiIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- amitchandakSuper User
cklopper , I think problem of placement of )
Try like
CALCULATE(Account[Total Count Account Codes], CONTAINSSTRING(Account[RegionalAccountClass],"abc" ) ||
'Account'[RegionalAccountClass] = "xyz")or
CALCULATE(Account[Total Count Account Codes],filter(Account, CONTAINSSTRING(Account[RegionalAccountClass],"abc" ) ||
'Account'[RegionalAccountClass] = "xyz"))refer
https://docs.microsoft.com/en-us/dax/containsstring-function-dax
- AnonymousNot applicable
cklopper , Alternative for CONTAINSTRING might be FIND.
Meanwhile, you can use the following DAX:
Original DAX:
CALCULATE(Account[Total Count Account Codes],
CONTAINSSTRING(Account[RegionalAccountClass],"abc" ) ||
CONTAINSSTRING('Account'[RegionalAccountClass] = "xyz"))New DAX:
CALCULATE(Account[Total Count Account Codes], OR( CONTAINSSTRING(Account[RegionalAccountClass],"abc" ), CONTAINSSTRING('Account'[RegionalAccountClass], "xyz") )- cklopperFrequent Visitor
Anonymous, amitchandak thanks for the suggestions. Unfortunately CONTAINSSTRING doesn't work because I'm connected directly to SQL Server Analysis Services. It's not available as a function and PBI Desktop won't recognise it... 😞
- v-yingjlCommunity Support
Hi cklopper ,
Sorry for replying late. Plese check the SSAS version you are running as the CONTAINSSTRING function only works from >= SSAS 2019 CTP2.3.
You can refer this simliar issue:
Best Regards,
Yingjie LiIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.