Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi,
How do I use the GroupBy and Having clause in my dataset? I have the following table:
[ORDER]
CUSTOMER ID NORDER NET AMOUNT
C1 1 100
C1 2 -100
C2 3 400
C4 4 0
C4 5 100
C5 6 100
I want to exclude the CUSTOMER ID C1 because he has the SUM of the NET AMOUNT=0 in another measure that counts thecustomers that have order. The SQL Statement could be this:
Select CUSTOMERS ID, SUM(NET AMOUNT)
FROM ORDER
GROUP BY CUSTOMERS ID
HAVING SUM(NET AMOUNT)<>0;
The measure that I want to filter is:
Hi, I have requirement with having clause and also distinct count and sum function in two different tables.
Can anyone help me how to write the measure for it.
Below is the logic we need to implement as measure.
Count distinct userevents.outletcode having sum(userevents.sessioncount)>0/ count of distinct outlet.outletcode where b2b flag=""x"" and outlet.outletstatuscodd=""2"" and outlet.b2bstartdate<=<date selected>
Kindly help how to implement this logic in dax
Hi @Anonymous
Here are a couple of ways you could write this measure.
The key part of the measure is FILTER( VALUES ( 'ORDER'[CUSTOMER ID] ),...), which is similar to the HAVING clause in your SQL example.
Customers with Nonzero Amount = CALCULATE ( DISTINCTCOUNT ( 'ORDER'[CUSTOMER ID] ); FILTER ( VALUES ( 'ORDER'[CUSTOMER ID] ); CALCULATE ( SUM ( 'ORDER'[NET AMOUNT] ) ) <> 0 ) )
Customers with Nonzero Amount = COUNTROWS ( FILTER ( VALUES ( 'ORDER'[CUSTOMER ID] ); CALCULATE ( SUM ( 'ORDER'[NET AMOUNT] ) ) <> 0 ) )
Regards,
Owen
Hi Owen,
thank you a lot for the answer . I've tried but it still does not work. This is the new measure:
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
146 | |
87 | |
66 | |
52 | |
46 |
User | Count |
---|---|
215 | |
90 | |
83 | |
66 | |
58 |