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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
will_lamslecz
New Member

Get orders from top 10% of customers

Hello, 
I am trying to create a measure that returns the number of orders from the customers who make up the top 10% of sales. For example, if total sales is $100, and the top 4 customers make up $10 of sales, and those 4 customers have a collective 20 orders, it would return 20. 
I'd like to know how I could go about doing this.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file whether it suits your requirement.

Please be noted that in my sample, I tried to find top 50 % customers order count.

 

Jihwan_Kim_1-1710796781456.png

 

 

Jihwan_Kim_0-1710796724663.png

 

 

 

Sales: = 
    SUM( sales[sales] )

 

 

 

Order count: = 
    COUNTROWS(sales)

 

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

 

top % sales: = 
VAR _allsales =
    CALCULATE ( [Sales:], REMOVEFILTERS ( customer ) )
VAR _runningsalesdesc =
    CALCULATE (
        [Sales:],
        WINDOW (
            1,
            ABS,
            0,
            REL,
            ALL ( customer[customer_id] ),
            ORDERBY ( [Sales:], DESC )
        )
    )
VAR _percentage =
    DIVIDE ( _runningsalesdesc, _allsales )
RETURN
    _percentage

 

 

 

Top 50% customer ordercount = 
VAR _customerlist =
    FILTER ( VALUES ( customer[customer_id] ), [top % sales:] <= 0.5 )
RETURN
    CALCULATE (
        [Order count:],
        FILTER ( customer, customer[customer_id] IN _customerlist )
    )

 

 


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

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @will_lamslecz ,

 

Jihwan_Kim said it very well, his method is very good.

 

You can try my different method.

 

Please follow my steps below:

 

First, here is the sample data I created, which are the Sales table and the Order table.

vhuijieymsft_0-1710825537978.png

vhuijieymsft_1-1710825537980.png

 

Second, create a calculated column that ranks customers based on their sales.

Customer Sales Rank = RANKX(ALL(Sales), Sales[Sales], , DESC, Dense)

 

Finally, create a calculated column to take out the information of the first four customers.

 

If it is the first four customers, it is equal to true, if not, it is equal to false.

Is Top Customer = IF(Sales[Customer Sales Rank] IN { 1,2,3,4}, TRUE, FALSE)

 

Apply the measure to a visual-level Filter that only displays True.

vhuijieymsft_2-1710825623842.png

 

pbix file is attached.

 

I would be grateful if you could provide me with sample data for testing, please remove any sensitive data in advance.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file whether it suits your requirement.

Please be noted that in my sample, I tried to find top 50 % customers order count.

 

Jihwan_Kim_1-1710796781456.png

 

 

Jihwan_Kim_0-1710796724663.png

 

 

 

Sales: = 
    SUM( sales[sales] )

 

 

 

Order count: = 
    COUNTROWS(sales)

 

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

 

top % sales: = 
VAR _allsales =
    CALCULATE ( [Sales:], REMOVEFILTERS ( customer ) )
VAR _runningsalesdesc =
    CALCULATE (
        [Sales:],
        WINDOW (
            1,
            ABS,
            0,
            REL,
            ALL ( customer[customer_id] ),
            ORDERBY ( [Sales:], DESC )
        )
    )
VAR _percentage =
    DIVIDE ( _runningsalesdesc, _allsales )
RETURN
    _percentage

 

 

 

Top 50% customer ordercount = 
VAR _customerlist =
    FILTER ( VALUES ( customer[customer_id] ), [top % sales:] <= 0.5 )
RETURN
    CALCULATE (
        [Order count:],
        FILTER ( customer, customer[customer_id] IN _customerlist )
    )

 

 


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

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.