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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
BM4291
Resolver I
Resolver I

Find X best performing area

Hi,

 

Struggling with something at the moment and having scoured the web I keep finding myself going over the same articles and not getting any closer to where I would like to be... Maybe searching for the wrong things!

 

In short, I want to know the following.

  1. Top/Bottom performing area - I have this sorted and have followed the steps here: https://community.powerbi.com/t5/Quick-Measures-Gallery/Top-1-per-category/m-p/225700
  2. Top/Bottom performing area excluding some i.e. I don't want one or two areas to be included in the calculation.
  3. 2nd/3rd/4th/Xth best performing area i.e. a dynamic calculation to tell me who is Xth best performing

 

I've tried using a modified version of the formula in 1 using RANKX but it's returning an unexpected result.

 

Can't share my data unfortunately but anonymised and simplified below:

 

181011 TOPN Example.png

 

The data table, call it Table1 is joined to a Team and Date dimension, Team is structured as below:

 

ID | Team | Area
1 | T1 | S1
2 | T2| S1
3 | T1 | S2

4 | T1 | S3

 

etc... For this we're just interested in the Area, not the individual teams within it.

 

Currently using the below measures in PBI

 

Staff = DISTINCTCOUNT(Table1[ID])

StaffB1 = CALCULATE([Staff], Table1[Band] = 1)

StaffB2 = CALCULATE([Staff], Table1[Band] = 2)

StaffB1B2 = [StaffB1] + [StaffB2] ... Would StaffB1B2 = CALCULATE([Staff], Table1[Band] = 1 || Table1[Band] = 2) be more performant?

%StaffB1B2 = DIVIDE([StaffB1B2], [Staff], 0)

%StaffB1B2Rank = RANKX(ALL(Teams), [%StaffB1B2])

%StaffB1B2BestArea = CALCULATE(
    LASTNONBLANK (Team[Area], 1),
    FILTER (
        TOPN(1, VALUES(Team[Area]), [%StaffB1B2], DESC), TRUE()
        )
)

%StaffB1B2BestAreaValue = CALCULATE (
[%StaffB1B2],
FILTER ( TOPN ( 1, VALUES ( Team[Area] ), [%StaffB1B2], DESC ), TRUE () )

 

When I filter this data to the latest month (as in the screenshot), I get S3 showing as top which whilst strictly true, it's a bit of an anomaly, it shouldn't be counted in the calculations, along with a few others and what I can't get my head around is how to exclude this, or focus on the 2nd best if it (or one of the others is 1st placed)... Any ideas at all?

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @BM4291,

 

I'd like some sample data with expected result for test and coding formula, it is hard to coding formula from snapshot.

 

Notice: some of fake data with same data structure and relationship.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

@v-shex-msft does the below help?

 

 

TeamIDDateIDBand
101/10/20181231
201/10/20183212
101/10/20184561
101/09/20181232
201/08/20183211
301/10/20184561
301/10/20187893
301/09/20184563
301/08/20184561
301/10/20187891

This table is then joined to a standard Date Dimension and a team table that looks like the below:

 

IDTeamArea
1T1S1
2T2S1
3T1S2
4T1S3

 

Hopefully this is a bit more helpful, let me know if you need anything else.

Hi @BM4291,

 

You measure seems not works on sample data, I try to write '1+2 percent' and 'Top area' measure and it works on my side. 

 

Maybe you can take a look at following measures:

1+2 percent = 
DIVIDE (
    CALCULATE ( DISTINCTCOUNT ( Table1[ID] ), Table1[Band] IN { 1, 2 } ),
    CALCULATE ( DISTINCTCOUNT ( Table1[ID] ), ALLSELECTED ( Table1 ) ),
    -1
)

Top Area = 
VAR currArea =
    SELECTEDVALUE ( Table2[Area] )
VAR temp =
    TOPN (
        1,
        ADDCOLUMNS ( ALLSELECTED ( Table2[Area] ), "Percent", [1+2 percent] ),
        [Percent], DESC
    )
RETURN
    IF ( CONTAINS ( temp, Table2[Area], currArea ), "Y" )

52.gif

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Sorry, that's not quite what I'm after (although does give some food for thought).

 

The %1+2 needs to be based on each area rather than the whole. Hence when using my data 'S3' is always coming up as the highest because it is 100%, what I need to be able to do is exclude it, and some others from the calculation.

 

We can find top 1, we can find bottom 1 but it's odd that there doesn't seem to be a straight-forward way of finding the 3rd/4th/5th best etc.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.