Forum Discussion

nkasdali's avatar
nkasdali
Icon for Microsoft Employee rankMicrosoft Employee
7 years ago

Dax calculated column with IF

Hi All,

I need your help in dax matters.

 

I'm trying to add a column into my dataset as flag to identify if my value is greater then the Percentil if this same value : here my dax

 

QuadrantTurnover V2 = 
Var vTurn = Data[Turnover/Month] //default field in my table
var vPerc = CALCULATE(PERCENTILE.INC(Data[Turnover/Month];0,8);ALLEXCEPT('Data';Data[EAN];'Data'[Country];Data[Product];'Data'[Time Period]))
return 
IF(vTurn>vPerc;"TOP";"BOTTOM")

and honestly, i can't understand the result ! :

PercentileTurnover is a measure  : 

CALCULATE(PERCENTILE.INC(Data[Turnover/Month];0,8);ALLEXCEPT('Data';Data[EAN];'Data'[Country];Data[Product];'Data'[Time Period]))

 

what i'am doing wrong ?

thanks for your help :)

 

5 Replies

  • v-cherch-msft's avatar
    v-cherch-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi nkasdali 

    You may create the measure like below:

    QuadrantTurnover V2 =
    VAR vTurn =
        SUM ( Data[Turnover/Month] ) 
    VAR vPerc =
        CALCULATE (
            PERCENTILE.INC ( Data[Turnover/Month]; 0,8 );
            ALLEXCEPT (
                'Data';
                Data[EAN];
                'Data'[Country];
                Data[Product];
                'Data'[Time Period]
            )
        )
    RETURN
        IF ( vTurn > vPerc; "TOP"; "BOTTOM" )
    

    Regards,

    • nkasdali's avatar
      nkasdali
      Icon for Microsoft Employee rankMicrosoft Employee

      hi v-cherch-msft 

      i thought about the measure, but, i'll lose the flag after ! i want to use the field as slicer.

       

      regards

      • v-cherch-msft's avatar
        v-cherch-msft
        Icon for Microsoft Employee rankMicrosoft Employee

        Hi nkasdali 

        If you want to use the field as slicer.You may create a calculated column.

        Regards,