Forum Discussion

nutyfreshz's avatar
nutyfreshz
Frequent Visitor
4 years ago

Quartile Labels

I want to labels frequency column each customer(linelog) as quartile calculate

but f_quatile apeared only Q4.

 

f_quartile = 
VAR frequent =
    SUM ( '040222_Villa_RFAnalysis'[frequency] )
VAR CustomerList =
    GROUPBY (
        ALL ( '040222_Villa_RFAnalysis' ),
        '040222_Villa_RFAnalysis'[lineLog],
        "Val", SUMX ( CURRENTGROUP (), [frequency] )
    )
VAR Percentile50 =
    MEDIANX ( CustomerList, [Val] )
VAR Percentile75 =
    MEDIANX ( FILTER ( CustomerList, [Val] >= Percentile50 ), [Val] )
VAR Percentile25 =
    MEDIANX ( FILTER ( CustomerList, [Val] < Percentile50 ), [Val] )
RETURN
    IF (
        frequent >= Percentile75,
        "Q4",
        IF ( frequent >= Percentile50, "Q3", IF ( frequent >= Percentile25, "Q2", "Q1" ) )
    )

 

I miss anythings?

Thank you.

1 Reply

  • nutyfreshz Do you have enough data points to disambiguate the quartiles?  Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to work with. Please show the expected outcome.