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.
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:
Solved! Go to Solution.
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 Li
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
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 Li
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
@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... 😞
@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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
93 | |
84 | |
66 |