Forum Discussion

vemee's avatar
vemee
Regular Visitor
2 years ago
Solved

Help calculating simpson's diversity index

Hi, I am rather new to Power BI, and would be truly greatfull for some help. I would like to calculate the simpson's diversity index based on the data avaliblie in my report. The calculation is ra...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi vemee ,

    Here some steps that I want to share, you can check them if they suitable for your requirement.

    Here is my test data:


    Create a calculate column

    Simpson's Diversity Index = 
    VAR Total_Observations = COUNTROWS('Table')
    VAR Value_Occurrences = 
        CALCULATE(
            COUNTROWS('Table'),
             FILTER('Table',
              'Table'[Colors] = EARLIER('Table'[Colors])
            )
        )
    RETURN
    1 -  SUMX('Table',Value_Occurrences * (Value_Occurrences-1)) / (Total_Observations * (Total_Observations - 1))

    Final output

     

    Best regards,

    Albert He

     

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