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
Anonymous
Not applicable

Create Histogram using Quartiles

Hi Everyone,

I am looking at creating a histogram that will show the average tenure of employees by quartiles. 

 

I used the below code to try and get quartiles however I can't seem to use this in a bar chart to mimic a histogram.  So basically I would like the quartiels across the bottom of the histogram/bar chart as the X axis and then count of employees that fall into each bucket. 

 

The other issue I noticed with the below code is I seem to have to pull in Tenure into the table in order for the below calculation to show the quartiles.  I would like a user to be able to select different locations and then get the quartiles for that location. 

 

I also want to apply this to employee wages as well but am using tenure as a test.

 

 

Quartile Avg Tenure = 
VAR FirstQ =
    PERCENTILEX.INC (
        ALL ( 'DimEmployees'[Tenure] ),
        'DimEmployees'[Tenure],
        .25
    )
VAR SecondQ =
    PERCENTILEX.INC (
        ALL ( 'DimEmployees'[Tenure] ),
        'DimEmployees'[Tenure],
        .50
    )
VAR ThirdQ =
    PERCENTILEX.INC (
        ALL ( 'DimEmployees'[Tenure] ),
        'DimEmployees'[Tenure],
        .75
    )
VAR ThisVal =
    SELECTEDVALUE ( 'DimEmployees'[Tenure] )
RETURN
    IF (
        ThisVal <= FirstQ,
        1,
        IF (
            ThisVal > FirstQ
                && ThisVal <= SecondQ,
            2,
            IF ( ThisVal > SecondQ && ThisVal <= ThirdQ, 3, 4 )
        )
    )

 

 

2 REPLIES 2
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

Can you please share a dummy file? If you can't, please share some sample data and your expected results that will make us understand clearly about your requirement.

 

Please see this post regarding How to Get Your Question Answered Quickly: 

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-xuding-msft , how is this?  and thanks for the reply.

 

sample data:

 

Employee ID            Tenure      Location

abc                               .4           A

def                              1.2           B

g                                  .5            B

h                                  5              A

i                                    4.2            B

 

Expected Results:

These are assigned quartiles dynamically which I can then put into a histogram.  So above another column of Quartiles/percentiles would be added but it can change depending on what location(s) you choose.  The histogram can be a bar chart but would look somethign like below.  Where the X axis are the quartiles and the Y axis is the employee count.

 

Does this help?

 

histogram.png

 

 

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.