Forum Discussion

cabadart's avatar
cabadart
Microsoft Employee
6 years ago
Solved

Display specific percentiles in a table

My goal is to create this table for my Age Data: Percentile Age 50   75   90   95   99   99.9   99.99     My data is in the form of Age and the count for that ag...
  • v-zhenbw-msft's avatar
    v-zhenbw-msft
    6 years ago

    Hi cabadart ,

     

    We can create three columns and four measures to meet your requirement.

     

    1. First delete the relationship between two tables.

     

     

    2. Create three columns of percentages separately.

     

    A % = 
    var x = CALCULATE(
    	SUM('AgeData'[Count]),
    	FILTER(
    		'AgeData',
            AgeData[Category] = "A"&&
    		AgeData[Age]<=EARLIER(AgeData[Age])
    	)
    )
    var y = CALCULATE(SUM(AgeData[Count]),FILTER(ALLSELECTED(AgeData),AgeData[Category]="A"))
    return
    DIVIDE(x,y)

     

    B % = 
    var x = CALCULATE(
    	SUM('AgeData'[Count]),
    	FILTER(
    		'AgeData',
            AgeData[Category] = "B"&&
    		AgeData[Age]<=EARLIER(AgeData[Age])
    	)
    )
    var y = CALCULATE(SUM(AgeData[Count]),FILTER(ALLSELECTED(AgeData),AgeData[Category]="B"))
    return
    DIVIDE(x,y)

     

    C % = 
    var x = CALCULATE(
    	SUM('AgeData'[Count]),
    	FILTER(
    		'AgeData',
            AgeData[Category] = "C"&&
    		AgeData[Age]<=EARLIER(AgeData[Age])
    	)
    )
    var y = CALCULATE(SUM(AgeData[Count]),FILTER(ALLSELECTED(AgeData),AgeData[Category]="C"))
    return
    DIVIDE(x,y)

     

     

    3. Then we can create four measures to get A, B, C and All.

     

    A = CALCULATE(MIN(AgeData[Age]),FILTER(AgeData,AgeData[A %]>=MAX(PercentilesToDisplay[Percentile])))

     

    B = CALCULATE(MIN(AgeData[Age]),FILTER(AgeData,AgeData[B %]>=MAX(PercentilesToDisplay[Percentile])))

     

    C = CALCULATE(MIN(AgeData[Age]),FILTER(AgeData,AgeData[C %]>=MAX(PercentilesToDisplay[Percentile])))

     

    All = CALCULATE(MIN(AgeData[Age]),FILTER(AgeData,AgeData[%]>=MAX(PercentilesToDisplay[Percentile])))

     

    Put them to values and not add category to column, the result like this,

     

     

    If you have any question, please kindly ask here and we will try to resolve it.

    BTW, pbix as attached. 

     

    Best regards,

     

    Community Support Team _ zhenbw

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.