Forum Discussion

nickchobotar's avatar
nickchobotar
Skilled Sharer
7 years ago
Solved

Dynamically return percentiles values

Hello,   I would appreciate some help with building a virtual table that would dynamically calculate percentiles based on the Cartesian product of two physical (unrelated) tables. In my model my ph...
  • TomMartens's avatar
    7 years ago

    Hey,

     

    this DAX statement ...

     

    Table = 
    var tblCrossJoin = CROSSJOIN('Sales', 'Percentiles')
    return
    ADDCOLUMNS(
        tblCrossJoin
        ,"percentileAmount"
            ,var currentClientID = 'Sales'[ClientId]
            var currentPercentile = 'Percentiles'[Percentile K]
            var sumAmount = CALCULATE(SUM('Sales'[Amount]))
            return
            PERCENTILEX.INC(
            FILTER(
                tblCrossJoin
                ,'Sales'[ClientId] = currentClientID && 'Percentiles'[Percentile K] = currentPercentile       
            )
            ,'Sales'[Amount] * 1.0, currentPercentile
        )
    )
    		
    

    ... helps to create this table ...

     

     

    It looks pretty much the same as your expected result.

     

    Hopefully it is what you are looking for.

     

    Regards,

    Tom