Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Calculating Percentage

 

 

can anyone point to me where am i wrong? 

i can't seems to get the correct percentage :C 

 

any idea how to share files for others to help troubleshoot? 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    Due to I don't know your data model, here I will give you some suggestions.

    Count =
    IF (
        HASONEVALUE ( 'TableName'[Column in Matrix Column] ),
        DIVIDE (
            DISTINCTCOUNT ( 'UCS_Appointment_Data'[a_centerclientid] ),
            SUM ( 'Enrollment_Numbers'[Enrollment Numbers (including Part time and fill time courses] )
        ),
        DIVIDE (
            CALCULATE (
                DISTINCTCOUNT ( 'UCS_Appointment_Data'[a_centerclientid] ),
                FILTER (
                    ALL ( UCS_Appointment_Data ),
                    UCS_Appointment_Data[Type of Status] = MAX ( 'TableName'[Column in Matrix Row] )
                )
            ),
            CALCULATE (
                SUM ( 'Enrollment_Numbers'[Enrollment Numbers (including Part time and fill time courses] ),
                FILTER (
                    ALL ( 'Enrollment_Numbers' ),
                    'Enrollment_Numbers'[Type of Status] = MAX ( 'TableName'[Column in Matrix Row] )
                )
            )
        )
    )

    If this reply still couldn't help you solve your issue, please share a sample file with me.

     

    Best Regards,
    Rico Zhou

     

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

5 Replies

  • Hi,

    Maybe it's not working due to row/filter context.

    Try this:




    Measure = 
    VAR UCS = DISTINCTCOUNT('UCS_Appointment_Data'[a_centerclientid])
    VAR Enrollment  = SUM('Enrollment_Numbers'[Enrollment Numbers (including Part time and fill time courses])
    return DIVIDE(UCS, Enrollment)

    Obs.: Please, spell check the names of tables and columns 'cause I may have misspelled something.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the prompt reply!!!
      it yield the same results.

       

      i think i know what is the error, but i cannot seem to solve it.

      the denominator is always fixed. Any idea how to solve this ? 

       

      • flath's avatar
        flath
        Helper II

        Now it looks you'll need to fix the relationship between tables.
        I think maybe the field that contains the data "2020/2021, 2021/2022, 2022/2023"... can't find a relationship beteween both tables.

        In my models, when I have a situation like that I find useful to create a composite key on both tables e create a relationship using this composite key.