Forum Discussion

Mainer04401's avatar
Mainer04401
Helper III
6 years ago
Solved

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 Reply