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
gmat
Helper I
Helper I

Need Assistance: Filtering Top 5 Customers by Margin % with Unit Requirement Challenge

I'm currently working on creating a matrix that displays the top 5 customers based on Margin %, but I'm encountering a challenge. I want to include only those customers who have 5 or more units. Unfortunately, the current setup isn't populating the field with any information.

 

I suspect the issue arises because the top 5 customers by Margin % in the entire dataset have fewer than 5 units. Ideally, I would like to narrow down the population, filtering it to include only customers with 5 or more units, and then determine the top 5 based on Margin % within that subset.

 

Has anyone encountered a similar situation or have suggestions on how to address this?

 

Thanks in advance for your help!

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

You can use your units measure as a filter on your TOPN like this.

 

Top 5 Margin % = 
CALCULATE (
    [Margin %],
    KEEPFILTERS (
        TOPN (
            5,
            FILTER ( ALL ( Customer[CustomerKey] ), [Units] > 5 ),
            [Margin %]
        )
    )
)

 

jdbuchanan71_0-1708476679300.png

 

 

 

View solution in original post

3 REPLIES 3
jdbuchanan71
Super User
Super User

You can use your units measure as a filter on your TOPN like this.

 

Top 5 Margin % = 
CALCULATE (
    [Margin %],
    KEEPFILTERS (
        TOPN (
            5,
            FILTER ( ALL ( Customer[CustomerKey] ), [Units] > 5 ),
            [Margin %]
        )
    )
)

 

jdbuchanan71_0-1708476679300.png

 

 

 

Can I also use this for bottom 5?

Yep, you just need to change the sort order, like this.

Bottom 5 Margin % = 
CALCULATE (
    [Margin %],
    KEEPFILTERS (
        TOPN (
            5,
            FILTER ( ALL ( Customer[CustomerKey] ), [Units] > 5 ),
            [Margin %],
            ASC
        )
    )
)

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.