Forum Discussion

samcaicn's avatar
samcaicn
Frequent Visitor
9 years ago
Solved

want sorting by Percentage

Data column”SEX“ is ”0“ and ”1“; Axis is ”REGION“, Value is ”SEX“ percentage; can't sorting by male(0) percentage, ps help,thanks
  • ceebu's avatar
    ceebu
    9 years ago

    You can use the CALCULATE function to count filtered values.

     

    Male %age = CALCULATE(Count([sex]),[sex] = "Male") / Count([sex])

8 Replies

  • Have you tried the latest version of PBI Desktop ? see below:

     

     

     

     

    • samcaicn's avatar
      samcaicn
      Frequent Visitor
      Male percentage = DIVIDE(COUNTROWS('JK_STUDENT_BASE'[MALE]),COUNTROWS('JK_STUDENT_BASE'[SEX]))
    • samcaicn's avatar
      samcaicn
      Frequent Visitor
      newest, only can sorting by ”SEX“ counting, cant by "SEX"(0)’s percentage
    • samcaicn's avatar
      samcaicn
      Frequent Visitor
      MALE = IF(---- CONDITION ---- JK_STUDENT_BASE[SEX] = 1, ---- THEN ---- JK_STUDENT_BASE[SEX], ---- ELSE ---- BLANK() )
      • v-huizhn-msft's avatar
        v-huizhn-msft
        Icon for Microsoft Employee rankMicrosoft Employee

        Hi samcaicn,

        The MALE is a calculated column? The synax of COUNTROWS function is COUNTROWS(<table>). Why you use column rather than table?  Why you use Could you please share the complete DAX and your sample data for further analysis? So we can post the solution which is close your requirement. It's hard to reproduce your scenario. Thanks for understanding.

        Best Regards,
        Angelia