Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calculated column to count records less than value in same column

Hello All, 

 

I am struggling with something I thought was going to be simple enough, but hours later I need help!

 

I have the following dataset:

 

RecordSEMRYPercentile RankNormalised Percentile Rank
169152468.75100.00
269152468.75100.00
369152468.75100.00
469152468.75100.00
569152468.75100.00
669152468.75100.00
769152468.75100.00
869152468.75100.00
969152468.75100.00
1069152468.75100.00
1169152468.75100.00
1269152468.75100.00
1369152468.75100.00
1469152468.75100.00
1569152468.75100.00
165.96812435.4242.86
175.95712431.2535.71
185.94522425.0025.00
195.94522425.0025.00
205.93052410.420.00
215.93052410.420.00
225.93052410.420.00
235.93052410.420.00
245.93052410.420.00

 

In Excel I have formulas for M, R, Y, Percentile Rank & Normalisation

 

M = COUNTIF(B:B,"<"&B2) //counts all rows in the dataset < value

R = COUNTIF(B:B,"="&B2) // counts all rows in the dataset = value

Y =COUNT($A$2:$A$2235)

Percentile Rank = ((C2+(0.5*D2))/E2)*100

Normalised Rank = (F2-MIN(F:F))/((MAX(F:F)-MIN(F:F)))*100

 

I am really struggling to find the right formula in Power BI for M & R . I cant seem to get anything working. 

 

Any help would be appreciated 🙂

10 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks so much parry2k and Ashish_Mathur , I am sooo very grateful for this.

      Amazing and super quick!

    • parry2k's avatar
      parry2k
      Super User

      Anonymous althought Ashish_Mathur proposed calcualted columns, I would recommend to use measures for performance, but it all depends how big your dataset is.


      Calculated column is the last thing you want to do. Cheers!!

  • Anonymous I think based on your sample dataset B2 = SE value 6 based on Record = 2, correct?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi parry2k , thanks yes cell B2 = 6,

      There are 9 records less than 6 and 15 values equal to 6 but cant seem to find a powerbi formula that gets this value. 

      • parry2k's avatar
        parry2k
        Super User

        Anonymous  here are measaures for you

         

        B2 Value = 
        CALCULATE (
            MAX ( Table1[SE] ),
            Table1[Record] = 2 
        )
        
        Count equal to B2 = 
        VAR __b2 = [B2 Value]
        RETURN
        CALCULATE (
            COUNTROWS ( Table1 ),
            Table1[Se] = __b2
        )
        
        Count less than B2 = 
        VAR __b2 = [B2 Value]
        RETURN
        CALCULATE (
            COUNTROWS ( Table1 ),
            Table1[Se] < __b2
        )