Forum Discussion
Need help with DAX to get similar function LIKE in SQL
- Anonymous3 years ago
I tried this method and it worked for import method,
src_rev = CALCULATE(SUM(AECG_VARICENT_INCENTIVE_HISTORY[SPLIT_AMOUNT]),NOT(CONTAINSSTRING(AECG_VARICENT_INCENTIVE_HISTORY[REVENUE_TYPE],"CRA")))Thanks for the answers and suggestions!
Hi,
Here is an example:
Dax:
End result:
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/
I understood the above concept or logic. But my issue is with the LIKE operator. How to implement that in DAX. And you can see it should filter the values starts with "CRA".
====> WHERE REVENUE_TYPE NOT LIKE '%CRA';
Not equal to would been easier but it is not!
- v-jianboli-msft3 years ago
Community Support
Hi Anonymous ,
You can create a DAX measure in Power BI to replicate the SQL query you provided. Here's a DAX measure that should give you the desired result:
Total Amount Excluding CRA = CALCULATE( SUM(TABLE1[AMOUNT]), FILTER( TABLE1, NOT (CONTAINSSTRING(TABLE1[REVENUE_TYPE], "CRA")) ) )This measure calculates the sum of the AMOUNT column in TABLE1 while excluding rows where the REVENUE_TYPE contains "CRA".
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.