Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

Help with ALLSELECTED & DISTINCTCOUNT

Hi!

I have created a report that show personel data. To visualize the number of employees for each visualisation I am using a DISTINCTCOUNT measure on the unique employee identifier. My issue now is that when I filter on, for example, country, the other visualizations shows the percentage of total, and not a percantage of total only in that country. 

How it looks without filter active

How it looks with a filter on Company

In the above view I would like the "Employee vs Consultants" + "Job Classifications" visuals to only show the percentage for the people in the chosen company, so that the sum is still 100%. I was hoping to achieve this with an ALLSELECTED measure, but I can't combine it with the DISTINCTCOUNT (to my knowledge), and if I only put ALLSELECTED(Employee_Identifier) the visual gives an error saying the measure is providing multiple inputs where there should only be one.

Thanks,

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    I also tried using a 
    CALCULATE(
      DISTINCTCOUNT('TABLE'[FIELD TO AGGREGATE])
      ALLSELECTED(FILTER)
    )

    But it returned the original result whatever i put in the filter

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Anonymous 

     

    Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

    Measure:

    Employee Percentage = 
    DIVIDE(
        DISTINCTCOUNT('Imformation'[employee]),
        CALCULATE(
            DISTINCTCOUNT('Imformation'[employee]),
            ALLSELECTED('Imformation')
        )
    )

     

    If this does not work, could you please share some sample data without sensitive information and expected output.
    How to provide sample data in the Power BI Forum - Microsoft Fabric Community

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum