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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
vinaydavid
Helper III
Helper III

Percentage Category for the Employee count - Bar Chart

Hi Experts,

 

I have a scenerio where the customers needs the user interaction with the bar chart.

The data looks like below, and I am after finding the count of Employees falling in the respective 'Percentage categories' based on the Percentage calculation.

 

LogDateNameHoursProd/ Non-prodSupervisor
22/11/2019A1Non-Work OrderSup_Name
22/11/2019A1Non-Work OrderSup_Name
22/11/2019A2.5Non-Work OrderSup_Name
22/11/2019A1.5Non-Work OrderSup_Name
21/11/2019A3.5Work OrderSup_Name
21/11/2019A1.5Work OrderSup_Name
20/11/2019A0.5Work OrderSup_Name
20/11/2019A4.5Work OrderSup_Name
19/11/2019A1Work OrderSup_Name
19/11/2019A1Work OrderSup_Name
19/11/2019B1.5Non-Work OrderSup_Name
19/11/2019B2Non-Work OrderSup_Name
14/11/2019B0.5Non-Work OrderSup_Name
14/11/2019B2Work OrderSup_Name
13/11/2019B1Work OrderSup_Name
13/11/2019B1.5Work OrderSup_Name
13/11/2019B1Work OrderSup_Name

 

Calculation: workorder / total (workorder + Non-work order)  --> for Employee A -> 12/18 = 67%

                                                                                                    --> for Employee B -> 5.5/9.5 = 58%

In the bar chart,

60% - 80% -----> 1

40% - 59% -----> 1

 

Something like this,1.JPG

And Customers needs this visual to be interactive, to be able to click on, for example "<50%" bar to analyze further.

 

I have used the below 'calculated column' to try to achieve this, but somehow I am getting the count too high and inaccurate values. (Also not sure if this approach is the right way of doing)

 

VAR __NUM = CALCULATE (
SUM ( 'Time Tracker Data'[Hours] ),
'Time Tracker Data'[Productive/ Non-productive] = "Work Order"
)
VAR __DEN = CALCULATE (
SUM ( 'Time Tracker Data'[Hours] ),
ALLEXCEPT('Time Tracker Data','Time Tracker Data'[Name],'Time Tracker Data'[LogDate])
)

VAR __PERC =
DIVIDE (__NUM,__DEN,0)

RETURN
IF (
__PERC > 0
&& __PERC <= 0.050,
"<50%",
IF (
__PERC > 0.050
&& __PERC <= 0.084,
"50% - 84%",
IF ( __PERC > 0.084 && __PERC <= 0.099, "85% - 99%", "100%" )
)
)
 

Please help!

Thanks for your help in advance!

vinaydavid

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

8 REPLIES 8
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur  Thanks for the inputs and file attachement.

 

The need is to have interactivity between visuals for further analysis.  

Like for example, if I change the logdate using a slicer, I might get 2 categories. Say <50% and 50% - 80%.

Then, we click on the <50% line item to see further details in other visuals to see leaves, meetings etc.,  

 

This bucket somehow has to link to the data, to see which Employee (perhaps other fields as well) corresponds to <50% for example?

Can this be achieved? 

Hi,

My solution should work.  Have you tried it?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur 

 

Thanks for the solution provided.

The approach of creating bucketted values was new for me. Thanks for that :-).

As it is, gives the desired result.

However, I noticed that, this gives the count of employees under a category, and will not be interactive as its not connected to any other tables.

 

Regards,

David

 

Hi,

You are welcome.  It will cross filter when you click on another visual.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

First calc should also have ALLEXCEPT('Time Tracker Data','Time Tracker Data'[Name]) ?

As calc are needed at the employee level

 

Also, refer :https://community.powerbi.com/t5/Desktop/SUM-of-AVERAGE/td-p/197013

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

 

 

Thanks @amitchandak  for the reply.

As suggested, When I use ALLEXCEPT for the numerator as well, the result is not as expected.

 

I am getting multiple 'Percentage' categories (Eg: 10%-30%, 70%-80%,..... etc.,) for a single Employee.

Where I would expect, 1 percentage category for Work Order and 1 for Non-Work order. (later will exclude Non-Work order)

 

Also, I have a Slicer based on 'Logdate'. But seems that this slicer values are not impacting the Calculated columns.

The results are weird.

 

Please help.

Some more inputs....

 

With Measure, I getting the right value....

But I can't plot this onto a bar graph..

 

measure.JPG

 

But with the use of calculated column, multiple percentage categories are being displyed. No clue, on how the DAX is working.

 

column.JPG

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.