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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
cklopper
Frequent Visitor

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:

 

CALCULATE(Account[Total Count Account Codes], CONTAINSSTRING(Account, Account[RegionalAccountClass], "abc" ||
    'Account'[RegionalAccountClass] = "xyz"))
1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community 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:

https://community.powerbi.com/t5/Desktop/CONTAINSSTRING-not-avaialble-when-Directly-Connected-to-TDM...

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yingjl
Community Support
Community 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:

https://community.powerbi.com/t5/Desktop/CONTAINSSTRING-not-avaialble-when-Directly-Connected-to-TDM...

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not 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")
)

 

 

 

@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... 😞

amitchandak
Super User
Super 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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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