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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Mainer04401
Helper III
Helper III

Quartile Groups

I built the measure below for calculating quartiles.  It works when I pull it into a store level list, but if I just pull the measure into the view without any store level context, it just says 4th quartile because it's not iterating through the stores.  I must be missing something.

 

Quartile (Sales) =

VAR FirstQ =

calculate(PERCENTILEX.EXC(SUMMARIZE(Table,Table[Site #],"Sales",[Sales (Scan)]),[Sales],.25),allselected(Table[Site #]))

VAR SecondQ =

calculate(PERCENTILEX.EXC(SUMMARIZE(Table,Table[Site #],"Sales",[Sales (Scan)]),[Sales],.50),allselected(Table[Site #]))

VAR ThirdQ =

calculate(PERCENTILEX.EXC(SUMMARIZE(Table,Table[Site #],"Sales",[Sales (Scan)]),[Sales],.75),allselected(Table[Site #]))

VAR ThisVal =

    SELECTEDVALUE ( Table[Sales] )

    VAR StoreLevel = VALUES(Table[Site #])

RETURN

    IF ( [Sales (Scan)] <= FirstQ,

        "1st Quartile",

        IF (

            [Sales (Scan)] > FirstQ

                && [Sales (Scan)] <= SecondQ,

            "2nd Quartile",

            IF ( [Sales (Scan)] > SecondQ && [Sales (Scan)] <= ThirdQ, "3rd Quartile", "4th Quartile" )

        )

    )

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi @Mainer04401 

In your formula, the row context is store level context, so you need to add store level in the visual, and it also involves measure total problem.

Please refer to these:

https://www.sqlbi.com/articles/row-context-and-filter-context-in-dax/

https://www.sqlbi.com/articles/row-context-and-filter-context-in-dax/https://community.powerbi.com/t...

https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

Quartile (Sales) =

VAR FirstQ =

calculate(PERCENTILEX.EXC(SUMMARIZE(Table,Table[Site #],"Sales",[Sales (Scan)]),[Sales],.25),allselected(Table[Site #]))

VAR SecondQ =

calculate(PERCENTILEX.EXC(SUMMARIZE(Table,Table[Site #],"Sales",[Sales (Scan)]),[Sales],.50),allselected(Table[Site #]))

VAR ThirdQ =

calculate(PERCENTILEX.EXC(SUMMARIZE(Table,Table[Site #],"Sales",[Sales (Scan)]),[Sales],.75),allselected(Table[Site #]))

VAR ThisVal =

    SELECTEDVALUE ( Table[Sales] )

    VAR StoreLevel = VALUES(Table[Site #])

RETURN

    IF ( [Sales (Scan)] <= FirstQ,

        "1st Quartile",

        IF (

            [Sales (Scan)] > FirstQ

                && [Sales (Scan)] <= SecondQ,

            "2nd Quartile",

            IF ( [Sales (Scan)] > SecondQ && [Sales (Scan)] <= ThirdQ, "3rd Quartile", "4th Quartile" )

        )

    )

 

Regards,

Lin

Community Support Team _ Lin
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

1 REPLY 1
v-lili6-msft
Community Support
Community Support

hi @Mainer04401 

In your formula, the row context is store level context, so you need to add store level in the visual, and it also involves measure total problem.

Please refer to these:

https://www.sqlbi.com/articles/row-context-and-filter-context-in-dax/

https://www.sqlbi.com/articles/row-context-and-filter-context-in-dax/https://community.powerbi.com/t...

https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

Quartile (Sales) =

VAR FirstQ =

calculate(PERCENTILEX.EXC(SUMMARIZE(Table,Table[Site #],"Sales",[Sales (Scan)]),[Sales],.25),allselected(Table[Site #]))

VAR SecondQ =

calculate(PERCENTILEX.EXC(SUMMARIZE(Table,Table[Site #],"Sales",[Sales (Scan)]),[Sales],.50),allselected(Table[Site #]))

VAR ThirdQ =

calculate(PERCENTILEX.EXC(SUMMARIZE(Table,Table[Site #],"Sales",[Sales (Scan)]),[Sales],.75),allselected(Table[Site #]))

VAR ThisVal =

    SELECTEDVALUE ( Table[Sales] )

    VAR StoreLevel = VALUES(Table[Site #])

RETURN

    IF ( [Sales (Scan)] <= FirstQ,

        "1st Quartile",

        IF (

            [Sales (Scan)] > FirstQ

                && [Sales (Scan)] <= SecondQ,

            "2nd Quartile",

            IF ( [Sales (Scan)] > SecondQ && [Sales (Scan)] <= ThirdQ, "3rd Quartile", "4th Quartile" )

        )

    )

 

Regards,

Lin

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.