cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
booooosevic Frequent Visitor
Frequent Visitor

How to group by measure?

Considering a ORDERS table, have customer_id, product_id, order_date columns.

 

In SQL, if we want to know

how many customers ordered a specified number of different products,

we could write the query like this:

select
	a.product_cnt,
	count( customer_id ) customer_cnt 
from
	( select 
			customer_id, 
			count( distinct product_id ) product_cnt 
		from orders a 
		group by a.customer_id ) a 
group by
	a.product_cnt;

I'm wondering how to achieve this in power bi with DAX.

What I want is a dynamic table, not a static derived static table. Means the output will change when the date filter is applied.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How to group by measure?

@booooosevic ,

 

You may take a look at the following post.

https://community.powerbi.com/t5/Desktop/Create-a-bar-graph-with-measures-as-axis/td-p/455900

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 REPLIES 2
Community Support Team
Community Support Team

Re: How to group by measure?

@booooosevic ,

 

You may take a look at the following post.

https://community.powerbi.com/t5/Desktop/Create-a-bar-graph-with-measures-as-axis/td-p/455900

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Super User
Super User

Re: How to group by measure?

Hey,

I guess you're looking for the DAX function COUNTDISTINCT.

Create a measure like so:
COUNTDISTINCT('orders'[product_id])

Hopefully this what you are looking for.

Regards,
Tom
Hamburg - Germany
If I answer you question, please mark my post as solution, this will also help others.
Proud to be a Datanaut!

Helpful resources

Announcements
Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Summit Australia 2019

Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

PBI Community Highlights

PBI Community Highlights

Check out what's new in the Power BI Community!

Top Ideas
Users Online
Currently online: 54 members 1,059 guests
Please welcome our newest community members: