Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
SajmenB
New Member

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

SajmenB_0-1706170671210.png

How it looks with a filter on Company

SajmenB_1-1706170711744.png

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 3
v-yaningy-msft
Community Support
Community Support

Hi, @SajmenB 

 

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.

vyaningymsft_0-1706257821591.png

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

https://drive.google.com/drive/folders/1g40xEHjmjFyWMiMkeLHAyET_Kg-E1rL8?usp=sharing

I hope you can find the pbix file here with the attached sample CSV file. I didn't manage to change the source myself from the sharepoint to the offline file.

 

You will notice when filtering on "Company" the other visuals does not show the percentage for that company only, but for the total. This is the issue.

SajmenB
New Member

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.