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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Chipsahoy1
Helper I
Helper I

Percentile based on a measure & Displaying +/- 25% based on Slicer Selection

Hi Everyone,

 

I have 2 questions I was hoping you could help me with.

 

The 1st question is can I create a measure to determine the percentile of a region/store/salesperson based on a measure that calculates avg sales (the avg sales is a measure that is total sales divided by total # of customers)?  See below for sample data sets. 

RegionAvg Sales
West$17,075
East$12,239
South$11,704
North$4,755

 

StoreAvg Sales
D$20,067
J$19,231
F$17,075
I$14,857
A$6,867
G$3,444
E$2,288
C$2,000
H$1,500
B$778

 

SalespersonAvg Sales
Henry$24,000
Marcus$21,053
Horatio$20,000
Maxine$19,231
Steven$8,333
Leory$7,500
Roberto$4,000
Rebecca$2,778
Elliot$2,381
Beth$2,182
Tommy$2,000
Amy$1,500
Jacob$1,304
John$1,000
Samantha$778
Valerie$667
Julie$400

 

I would also like to create a visual that shows which salespeople fall within +/-25% of a slicer selection.  So my 2nd question is how can I create a visual that lists the salespeople whose avg sales fall within +/-25% of the slicer selection's avg sales?  The slicer is the names of the salespeople.  I would also like this to be able to be done at a macro level such as region and store (from the above data samples).

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

I am not clear about your question.  Based on the data that you have shared, show the expected result very clearly.  Also, share the raw data to work with.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Elena_Kalina
Solution Specialist
Solution Specialist

Hi @Chipsahoy1 

Solution for 1st question

Try using the follow measure

Avg Sales Percentile = 
VAR AllSalespeople = 
    CALCULATETABLE(
        VALUES(SalespersonTable[Salesperson]),
        REMOVEFILTERS(SalespersonTable[Salesperson])
    )
VAR TotalRows = COUNTROWS(AllSalespeople)
VAR CurrentSalesperson = SELECTEDVALUE(SalespersonTable[Salesperson])
VAR CurrentRank = 
    IF(
        NOT ISBLANK(CurrentSalesperson),
        RANKX(
            AllSalespeople,
            [AvgSales],
            CALCULATE([AvgSales], SalespersonTable[Salesperson] = CurrentSalesperson),
            DESC
        ),
        BLANK()
    )
RETURN
IF(
    NOT ISBLANK(CurrentRank),
    DIVIDE(CurrentRank - 1, TotalRows - 1),
    BLANK()
)

in my case

AvgSales = 
AVERAGE('SalespersonTable'[AVG Sales])

since I used your data in the table and as I understood description [AVG Sales] columns  are measures in your case

Elena_Kalina_0-1751137104853.png

Solution for 2nd question

Create a Dedicated Slicer Table

Salesperson For Slicer = 
SELECTCOLUMNS(
    SalespersonTable,
    "Salesperson", SalespersonTable[Salesperson]
)

Purpose: This decouples the slicer from your main data table, preventing unwanted filtering of your visuals.

Create Measures

Selected Salesperson Avg = 
VAR SelectedPerson = SELECTEDVALUE('Salesperson For Slicer'[Salesperson])
RETURN
IF(
    NOT ISBLANK(SelectedPerson),
    CALCULATE(
        [AvgSales],
        FILTER(
            ALL(SalespersonTable),
            SalespersonTable[Salesperson] = SelectedPerson
        )
    ),
    BLANK()
)
Display Sales in Range = 
VAR SelectedAvg = [Selected Salesperson Avg]
VAR CurrentAvg = [AvgSales]
VAR LowerBound = SelectedAvg * 0.75
VAR UpperBound = SelectedAvg * 1.25
RETURN
IF(
    ISBLANK(SelectedAvg) || 
    (CurrentAvg >= LowerBound && CurrentAvg <= UpperBound),
    CurrentAvg,  // Display value
    BLANK()      // Hide from visual
)

Elena_Kalina_1-1751138519460.png

 

For Chart Visual:

Show Row = 
VAR SelectedAvg = [Selected Salesperson Avg]
VAR CurrentAvg = [Avg Sales Value]
RETURN
IF(
    ISBLANK(SelectedAvg) || 
    (CurrentAvg >= SelectedAvg*0.75 && CurrentAvg <= SelectedAvg*1.25),
    1,  // Include in visual
    0   // Exclude from visual
)

Elena_Kalina_2-1751138631856.png

 

Akash_Varuna
Community Champion
Community Champion

Hi @Chipsahoy1 For this use the RANKX function in DAX with a measure that divides the rank by the total count of rows. For filtering salespeople within ±25% of slicer selection, create measures for the lower and upper bounds (LowerBound and UpperBound) and a WithinRange measure to identify salespeople whose sales fall in this range. Use slicers for dynamic selection and filter visuals using the WithinRange measure.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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