cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vinaydavid
Helper III
Helper III

Count based on Percentage Category

Hi,

 

How should be go about to get the count of employees(distinct) in the below scenario.

 

ActivityEmpBudget hrshours
a12.52
b12.52
c12.52
x231
y231

 

Then I want to plot the count on a clustered bar chart...like below

 

For 2 employees:

Category (y-axis) 50% - 80% ----------> 1

                            30% - 49%-----------> 1

 

Thanks in advance for your time and efforts.

 

 

Regards,

David

1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community Support

Hi @vinaydavid ,

 

First of all, we need to create a calculated table as x-axis, you can change the value in this table to generate different category:

 

x-axis = 
ADDCOLUMNS (
    DATATABLE (
        "MinPercent", DOUBLE,
        "MaxPercent", DOUBLE,
        {
            { 0, 0.2 },
            { 0.21, 0.5 },
            { 0.51, 0.75 },
            { 0.76, 1 }
        }
    ),
    "Category", FORMAT ( [MinPercent], "0%" ) & " - "
        & FORMAT ( [MaxPercent], "0%" )
)

 

1.jpg

 

 Then we can create a measure as the value of this chart:

 

EmplyCount = 
COUNTX (
    FILTER (
        SUMMARIZE (
            'Table',
            'Table'[Emp],
            "Percent", DIVIDE ( SUM ( 'Table'[hours] ), SUM ( 'Table'[Budget hrs] ), 0 )
        ),
        [Percent] > MAX ( 'x-axis'[MinPercent] )
            && [Percent] < MIN ( 'x-axis'[MaxPercent] )
    ),
    [Emp]
)

 

2.jpg

 


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-lid-msft
Community Support
Community Support

Hi @vinaydavid ,

 

First of all, we need to create a calculated table as x-axis, you can change the value in this table to generate different category:

 

x-axis = 
ADDCOLUMNS (
    DATATABLE (
        "MinPercent", DOUBLE,
        "MaxPercent", DOUBLE,
        {
            { 0, 0.2 },
            { 0.21, 0.5 },
            { 0.51, 0.75 },
            { 0.76, 1 }
        }
    ),
    "Category", FORMAT ( [MinPercent], "0%" ) & " - "
        & FORMAT ( [MaxPercent], "0%" )
)

 

1.jpg

 

 Then we can create a measure as the value of this chart:

 

EmplyCount = 
COUNTX (
    FILTER (
        SUMMARIZE (
            'Table',
            'Table'[Emp],
            "Percent", DIVIDE ( SUM ( 'Table'[hours] ), SUM ( 'Table'[Budget hrs] ), 0 )
        ),
        [Percent] > MAX ( 'x-axis'[MinPercent] )
            && [Percent] < MIN ( 'x-axis'[MaxPercent] )
    ),
    [Emp]
)

 

2.jpg

 


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

sananthv
Helper II
Helper II

The first part is easy. If you want a count distinct and lets say your table is called Employees, we can create a measure as bellow.

 

DistinctEmp = DISTINCTCOUNT(Employees[Emp])

 

I did not understand the second part of the question

Thanks for your reply,

 

2nd part,

Is to find the Productivity % of each employee (Hours/Budgeted hours - which I can do) and based on the % values, I need to categorize and show the count of employees falling in say, 0% - 20%, 21% - 50%, 51% - 75% & 76% - 100% in a bar chart.

 

Thanks!

Hi @vinaydavid ,

 

How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!