Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
JoyceW
Helper II
Helper II

Distinct count and then create groups

Hi,

 

I'm looking for some help. 

 

I have a table with ordernumbers and invoicenumbers. Ordernumber is unique, but one order can have more invoicenumbers. 

So for example:

 

InvoicenumberOrdernumber
11
21
32
43
53
63
74
84

 

I want to group by how many invoices there are for an order. 

 

So first I created a measure: count of invoicenumber = calculate(distinctcount(table[invoicenumber]))

 

So now I have:

 

OrdernumberCount of invoices
12
21
33
42

 

Then I want to group by count of invoices, so I know how many times I have 1, 2, 3 etc. I don't know how to get there, but I would like the result to be like this:

 

Group of count of invoicesAmount
11
2-33
4 - more0

 

So then I will know that there are 3 orders which have 2 or 3 invoices, 0 orders with 4 or more invoices, e.g

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

One of ways to create this is having a Grouping table like below.

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Invioce count group measure: = 
COUNTROWS (
    FILTER (
        VALUES ( Data[Ordernumber] ),
        [Count of invoice measure:] >= MIN ( 'Grouping'[min] )
            && [Count of invoice measure:] <= MAX ( 'Grouping'[max] )
    )
) + 0

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

2 REPLIES 2
JoyceW
Helper II
Helper II

Yes! Thank you, this works like charm. 

Jihwan_Kim
Super User
Super User

Hi,

One of ways to create this is having a Grouping table like below.

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Invioce count group measure: = 
COUNTROWS (
    FILTER (
        VALUES ( Data[Ordernumber] ),
        [Count of invoice measure:] >= MIN ( 'Grouping'[min] )
            && [Count of invoice measure:] <= MAX ( 'Grouping'[max] )
    )
) + 0

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.