olap - Calculating PERCENTILE in DAX -
i have googled , keep ending formulas slow. suspect if split formula in steps (creating calculated columns), might see performance gain.
i have table having numeric columns along end slicers. intention have 10th, 25th, 50th, 75th , 90th percentile on numeric columns selected slicer.
this have 10th percentile on column "total pd".
totalpaid10thpercentile:=minx( filter( values(claimoutcomes[total pd]), calculate( countrows(claimoutcomes), claimoutcomes[total pd] <= earlier(claimoutcomes[total pd]) )> countrows(claimoutcomes)*0.1 ), claimoutcomes[total pd] )
it takes several minutes , still no data shows up. have around 300k records in table.
i figured out way break calculation down in series of steps, fetched pretty fast solution.
for calculating 10th percentile on amount paid
in table data
, followed below out-of-the-book formula :
calculate ordinal rank 10th percentile element
10ptordinalrank:=0.10*(countx('data', [amount paid]) - 1) + 1
it might come out decimal(fraction) number 112.45
compute decimal part
10ptdecpart:=[10ptordinalrank] - trunc([10ptordinalrank])
compute ordinal rank of element below(floor)
10ptfloorelementrank:=floor([10ptordinalrank],1)
compute ordinal rank of element above(ceiling)
10ptceilingelementrank:=ceiling([10ptordinalrank], 1)
compute element corresponding floor
10ptfloorelement:=maxx(topn([10ptfloorelementrank], 'data',[amount paid],1), [amount paid])
compute element corresponding ceiling
10ptceilingelement:=maxx(topn([10ptceilingelementrank], 'data',[amount paid],1), [amount paid])
compute percentile value
10thpercvalue:=[10ptfloorelement] + [10ptdecpart]*([10ptceilingelement]-[10ptfloorelement])
i have found performance remarkably faster other solutions found on net. hope helps in future.
Comments
Post a Comment