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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
herbemischung
Resolver I
Resolver I

Measures for Top 25 and Bottom 25 customers (in terms of sales amount) in order to compare to rest

Hey guys,

 

Hey, guys, I'm not really getting anywhere right now.

 

I'm trying to create a measure that will give me the top 25 clients' revenue.

Then I want a second measure that gives me the sales of the bottom 25 customers.

 

At the end I want to calculate the difference:

Sales >Bottom25 <Top25 = [Total sales] - [sales top 25 customers] - [sales bottom 25 customers]

 

Thanks! all the best, herbert

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@herbemischung , refer if these can help, Change column and measure as per need

TopN Customer = 
VAR SelectedTop = 25
RETURN
SWITCH(TRUE(),
    SelectedTop = 0, [Sales Amount],
    RANKX ( 
            ALLSELECTED(  'Customer'[Customer] ), 
            [Total Revenue], , desc,dense
                )
                  <= SelectedTop,
        [Sales Amount]
)


Bottom N Customer = 
VAR SelectedTop = 25
RETURN
SWITCH(TRUE(),
    SelectedTop = 0, [Sales Amount],
    RANKX ( 
            ALLSELECTED(  'Customer'[Customer] ), 
            [Total Revenue], , asc,dense
                )
                  <= SelectedTop,
        [Sales Amount]
)

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@herbemischung , refer if these can help, Change column and measure as per need

TopN Customer = 
VAR SelectedTop = 25
RETURN
SWITCH(TRUE(),
    SelectedTop = 0, [Sales Amount],
    RANKX ( 
            ALLSELECTED(  'Customer'[Customer] ), 
            [Total Revenue], , desc,dense
                )
                  <= SelectedTop,
        [Sales Amount]
)


Bottom N Customer = 
VAR SelectedTop = 25
RETURN
SWITCH(TRUE(),
    SelectedTop = 0, [Sales Amount],
    RANKX ( 
            ALLSELECTED(  'Customer'[Customer] ), 
            [Total Revenue], , asc,dense
                )
                  <= SelectedTop,
        [Sales Amount]
)
harshnathani
Community Champion
Community Champion

HI @herbemischung ,

 

 

Create a measure

 

Total Revenue = SUM(Table[Revenue])

 

Top25 = CALCULATE([Total Revenue],TOPN(25,'Table',[Total Revenue],DESC)

Bottom25 = CALCULATE([Total Revenue],TOPN(25,'Table',[Total Revenue],ASC)

 

RETURN

Revenue - Top25 - Bottom25

 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

@herbemischung ,

 

 

Total Revenue = SUMX(SalesTable,SalesTable[OrderQuantity]*related(Products[ProductPrice]))
 

Top25 = CALCULATE([Total Revenue],TOPN(25,'CustomerTable',[Total Revenue],DESC)

Bottom25 = CALCULATE([Total Revenue],TOPN(25,'CutomerTable',[Total Revenue],ASC)

 

RETURN

Revenue - Top25 - Bottom25

 

Regards,

HN

Hi, and thank you, but unfortunately it didn't work

 

I only get the total revenue, I guess because in your formula is no reference to the customer. 

@herbemischung ,

 

Please share your sample pbix file to help you better.

 

Table should be customer table.

 

Regards,

HN

Sorry, but I cannot share our company data. Thanks for trying!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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