Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
I am getting an issue in creating a DAX function in Power BI.
My Query
SELECT SUM(AMOUNT) FROM TABLE1
WHERE REVENUE_TYPE NOT LIKE '%CRA';
I want to replicate this thing in Power BI using DAX. Need some inputs
Thanks!
Solved! Go to Solution.
I tried this method and it worked for import method,
I tried this method and it worked for import method,
Hi,
Here is an example:
Dax:
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!
Proud to be a Super User!
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!
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.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
23 | |
21 | |
20 | |
14 | |
12 |
User | Count |
---|---|
43 | |
31 | |
25 | |
22 | |
22 |