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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
marksaba
Helper II
Helper II

Group Matrix into Dynamic Quartiles

I need assistance learning how to create dynamic quartile groupings that, when inputted into a matrix, will group by rows.

 

For instance, I have a table with Items in rows and Dollar Sales and Unit Sales as values. I want this quartile to be inputted before Items, showing Top 25% of Products by Dollar Sales, Next 25%, Next 25%, and Bottom 25%, each of which I can expand to view Items. If I were to have 200 items, this grouping would group the items into four groups of 50. If I filtered the table via a slicer to cut down the item list to 100 items, I would then want the groupings to group items into four groups of 25. 

 

Can somebody assist with how this can be achieved?

 

Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @marksaba ,

 

@Ritaf1983 , thanks for your concern about this case. I tried to create a sample data myself based on the user's requirement and implemented the result. Please check if there is anything that can be improved. Here is my solution: 

 

I am using the financials table provided by power bi as sample data.

vkaiyuemsft_0-1721723340195.png

 


1. create MEASURE to get the ranking of current sales.

MEASURE = 
VAR _rank =
    RANKX ( ALLSELECTED ( financials ), [_sum_sales],, ASC, DENSE )
RETURN
    _rank

 

2. Create MEASURE to display different names based on the rank.

Measure2 = 
VAR _max_rank =
    MAXX (
        SELECTCOLUMNS (
            ALLSELECTED ( financials ),
            'financials'[Product],
            "_Measure", [MEASURE]
        ),
        [_Measure]
    )
VAR _g1 =
    DIVIDE ( _max_rank, 4 )
VAR _g2 =
    DIVIDE ( _max_rank, 2 )
VAR _g3 = _g1 * 3
RETURN
    SWITCH (
        TRUE (),
        [MEASURE] <= _g1, "G1",
        [MEASURE] > _g1
            && [MEASURE] <= _g2, "G2",
        [MEASURE] > _g2
            && [MEASURE] <= _g3, "G3",
        [MEASURE] > _g3
            && [MEASURE] <= _max_rank, "G4"
    )

vkaiyuemsft_1-1721723393425.pngvkaiyuemsft_2-1721723400779.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

2 REPLIES 2
Anonymous
Not applicable

Hi @marksaba ,

 

@Ritaf1983 , thanks for your concern about this case. I tried to create a sample data myself based on the user's requirement and implemented the result. Please check if there is anything that can be improved. Here is my solution: 

 

I am using the financials table provided by power bi as sample data.

vkaiyuemsft_0-1721723340195.png

 


1. create MEASURE to get the ranking of current sales.

MEASURE = 
VAR _rank =
    RANKX ( ALLSELECTED ( financials ), [_sum_sales],, ASC, DENSE )
RETURN
    _rank

 

2. Create MEASURE to display different names based on the rank.

Measure2 = 
VAR _max_rank =
    MAXX (
        SELECTCOLUMNS (
            ALLSELECTED ( financials ),
            'financials'[Product],
            "_Measure", [MEASURE]
        ),
        [_Measure]
    )
VAR _g1 =
    DIVIDE ( _max_rank, 4 )
VAR _g2 =
    DIVIDE ( _max_rank, 2 )
VAR _g3 = _g1 * 3
RETURN
    SWITCH (
        TRUE (),
        [MEASURE] <= _g1, "G1",
        [MEASURE] > _g1
            && [MEASURE] <= _g2, "G2",
        [MEASURE] > _g2
            && [MEASURE] <= _g3, "G3",
        [MEASURE] > _g3
            && [MEASURE] <= _max_rank, "G4"
    )

vkaiyuemsft_1-1721723393425.pngvkaiyuemsft_2-1721723400779.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

Ritaf1983
Super User
Super User

Hi @marksaba 

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.