Forum Discussion
Percentile Category
Hi,
I am trying to categorize my percentile as below but kept on coming with value of Q4.
Can you please check what is wrong?
Thanks :)
PercentileCategory =
//find cutoff points for profit margin quartiles
VAR LowerMiddle = PERCENTILEX.INC(ALLSELECTED([AHT], 0.25)
VAR Middle = PERCENTILEX.INC (ALLSELECTED([AHT], 0.50)
Var UpperMiddle = PERCENTILEX.INC (ALLSELECTED([AHT], 0.75)
RETURN
//do nested if to set the category
IF([AHT] < LowerMiddle , "Q1",
IF([AHT] < Middle , "Q2",
IF([AHT] < UpperMiddle , "Q3",
IF([AHT] >= UpperMiddle, "Q4",
"NA"))))
5 Replies
- Greg_Deckler
Community Champion
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
Raw sample/example data would really help.
- Jennifer2018Regular Visitor
Hi
Thanks for the reply, sorry if it was confusing.
Here is a sample data. Note AHT is a measure and there is a date slicer and branch slicer so AHT value changes depending on period and branch selected.
Branch Month-Year AHT PctileCatg a Feb-18 435.1 Q4 b Feb-18 768.5 Q4 c Feb-18 393.2 Q4 d Feb-18 415.7 Q4 e Feb-18 603.3 Q4 f Feb-18 459.1 Q4 g Feb-18 395.4 Q4 h Feb-18 430.8 Q4 i Feb-18 672.5 Q4 j Feb-18 584 Q4 k Feb-18 448.2 Q4 l Feb-18 520.1 Q4 m Feb-18 576.3 Q4 n Feb-18 410.9 Q4 o Feb-18 420.1 Q4 p Feb-18 324.2 Q4 My end result is hopefully a bar graph of Pctile category and branch.
Appreciate any help. Thanks.
- Greg_Deckler
Community Champion
Thanks Jennifer2018. I believe what you want is a column like this:
PercentileCategory = //find cutoff points for profit margin quartiles VAR LowerMiddle = PERCENTILEX.INC(ALL(Percentiles),[AHT],.25) VAR Middle = PERCENTILEX.INC (ALL(Percentiles),[AHT],0.50) Var UpperMiddle = PERCENTILEX.INC (ALL(Percentiles),[AHT],0.75) RETURN //do nested if to set the category IF([AHT] < LowerMiddle , "Q1", IF([AHT] < Middle , "Q2", IF([AHT] < UpperMiddle , "Q3", IF([AHT] >= UpperMiddle, "Q4", "NA"))))
Note that "Percentiles" is my table and it is the one you supplied minus the last column. I get varying values for this column so I believe it is correct. Here is my output:
Percentiles (table)
Branch Month-Year AHT PercentileCategory (the formula above)
a Sunday, February 18, 2018 435.1 Q2 b Sunday, February 18, 2018 768.5 Q4 c Sunday, February 18, 2018 393.2 Q1 d Sunday, February 18, 2018 415.7 Q2 e Sunday, February 18, 2018 603.3 Q4 f Sunday, February 18, 2018 459.1 Q3 g Sunday, February 18, 2018 395.4 Q1 h Sunday, February 18, 2018 430.8 Q2 i Sunday, February 18, 2018 672.5 Q4 j Sunday, February 18, 2018 584 Q4 k Sunday, February 18, 2018 448.2 Q3 l Sunday, February 18, 2018 520.1 Q3 m Sunday, February 18, 2018 576.3 Q3 n Sunday, February 18, 2018 410.9 Q1 o Sunday, February 18, 2018 420.1 Q2 p Sunday, February 18, 2018 324.2 Q1 I'm actually a little surprise you were getting anything, there seemed to be syntax errors in the formula you posted.