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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Quartile Calculation

Can someone please help me to calculate

 

Percentage of customers that contribute the 1st quartile (top 25%) of revenue 
Percentage of customers that contribute the 2nd quartile (25%-50%) of revenue
Percentage of customers that contribute the 3rd quartile (50%-75%) of revenue
Percentage of customers that contribute the 4rd quartile (75%-100%) of revenue  
 
Basically, I need to show a bar chart which will display 4 bars for each quartile as mentioned above.
 
Thanks
1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

a1.png

 

Quartile:

a2.png

 

You may create a measure as below.

Percentage = 
var total = CALCULATE(DISTINCTCOUNT('Table'[CustomerID]),ALL('Table'))
var tab = 
ADDCOLUMNS(
    ALL('Table'),
    "Rank",
    RANKX(
        ALL('Table'),
        [Revenue Contribution],,ASC
    )
)
var newtab = 
SUMMARIZE(
    Quartile,
    Quartile[Quartile],
    "Count",
    SWITCH(
        [Quartile],
        "quartile1",
        DIVIDE(
            COUNTROWS(
                FILTER(
                    tab,
                    [Rank]>=1&&[Rank]<total*0.25
                )
            ),
            total
        ),
        "quartile2",
        DIVIDE(
            COUNTROWS(
                FILTER(
                    tab,
                    [Rank]>=total*0.25&&[Rank]<total*0.5
                )
            ),
            total
        ),
        "quartile3",
        DIVIDE(
            COUNTROWS(
                FILTER(
                    tab,
                    [Rank]>=total*0.5&&[Rank]<total*0.75
                )
            ),
            total
        ),
        "quartile4",
        DIVIDE(
            COUNTROWS(
                FILTER(
                    tab,
                    [Rank]>=total*0.75&&[Rank]<=total            )
            ),
            total
        )
    )
)
return
SUMX(
    newtab,
    [Count]
)

 

Result:

a3.png

 

Best Regards

Allan

 

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

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Please share some data to work with.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

a1.png

 

Quartile:

a2.png

 

You may create a measure as below.

Percentage = 
var total = CALCULATE(DISTINCTCOUNT('Table'[CustomerID]),ALL('Table'))
var tab = 
ADDCOLUMNS(
    ALL('Table'),
    "Rank",
    RANKX(
        ALL('Table'),
        [Revenue Contribution],,ASC
    )
)
var newtab = 
SUMMARIZE(
    Quartile,
    Quartile[Quartile],
    "Count",
    SWITCH(
        [Quartile],
        "quartile1",
        DIVIDE(
            COUNTROWS(
                FILTER(
                    tab,
                    [Rank]>=1&&[Rank]<total*0.25
                )
            ),
            total
        ),
        "quartile2",
        DIVIDE(
            COUNTROWS(
                FILTER(
                    tab,
                    [Rank]>=total*0.25&&[Rank]<total*0.5
                )
            ),
            total
        ),
        "quartile3",
        DIVIDE(
            COUNTROWS(
                FILTER(
                    tab,
                    [Rank]>=total*0.5&&[Rank]<total*0.75
                )
            ),
            total
        ),
        "quartile4",
        DIVIDE(
            COUNTROWS(
                FILTER(
                    tab,
                    [Rank]>=total*0.75&&[Rank]<=total            )
            ),
            total
        )
    )
)
return
SUMX(
    newtab,
    [Count]
)

 

Result:

a3.png

 

Best Regards

Allan

 

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

Anonymous
Not applicable

Hi, please note that the CustomerID and Revenue are in two different tables as per my data.

Could you please help on that

amitchandak
Super User
Super User

@Anonymous , I think you have Box and Whisker chart for that. See if that can help

https://appsource.microsoft.com/en-us/product/power-bi-visuals/WA104380831?tab=Overview

 

refer for quartile

https://sqldusty.com/2018/08/31/calculating-quartiles-with-dax-and-power-bi/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I tried but that's not working

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.