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
markefrody
Post Patron
Post Patron

Product Count Based on Shift

Hi,

 

I'm trying to count the number of products finished on each manager's time shift. Problem is each manager's shift changes every day.  

I have two tables containing the following:
Table 1: Manager Schedule
Contains the shift schedule 2 shift managers per day
https://www.dropbox.com/scl/fi/4qb4rdo43teyew7yp0x07/Manager-Sample-Data.xlsx?dl=0&rlkey=gk8xt5cgyqs...

Table 2: Production Schedule
List of products and time when the product was made. 
https://www.dropbox.com/s/7jh2hcycutk0zra/Schedule%20Sample%20Data.xlsx?dl=0 

pbix file containing the two tables and date table:
https://www.dropbox.com/s/mh1146kycg2hq1k/Product%20Count%20Based%20On%20Shift.pbix?dl=0

The output should look like this:

markefrody_0-1635549965551.png


Appreciate if you can help me out. Thanks!

Best regards,
Mark V

1 ACCEPTED SOLUTION

My bad, I misunderstood.
I kept the same changes mentioned above and added a new measure and created new visual. Please see if this helps

 

a) Created a measure part of manager schedule

 

Prod Count = 

var _d1 = Minx('Manager Schedule', 'Manager Schedule'[Start Time])
var _d2 = Minx('Manager Schedule', 'Manager Schedule'[Clock Out])
var _Prod_count = CALCULATE( COUNTROWS('Production Schedule'), FILTER('Production Schedule', 'Production Schedule'[Date Finished] >= _d1 && 'Production Schedule'[Date Finished] <= _d2))

return _Prod_count

 

 

sevenhills_0-1635794196338.pngsevenhills_1-1635794214120.png

 

 

 

View solution in original post

12 REPLIES 12
Ashish_Mathur
Super User
Super User

Hi,

Since you want the output to be date wise, I am assuming that the time stamp appearing in each of the 2 tables is not required.


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

@Ashish_Mathur 

Hi Ashish,

Thank you for your reply.

For the output, time stamp is not required.

Best regards,
Mark V. 


Hi,

There should be another table which maps the products to managers.


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

@Ashish_Mathur 

Hi Ashish,

I have created a pbix with date table to connect the tables together.
https://www.dropbox.com/s/mh1146kycg2hq1k/Product%20Count%20Based%20On%20Shift.pbix?dl=0

Please let me know if this helps. Thanks.

Best regards,
Mark V.

1. Create column as Date part only

 

Date Finished DT = DATEVALUE('Production Schedule'[Date Finished])

 

 

mark the format as "mm/dd/yyyy" to the new column

similar format to Manager schedule - start date column.

 

2. Adjust the model    and see if it works for your needs

sevenhills_0-1635789384467.png

 

sevenhills_1-1635789584486.png

 

sevenhills_2-1635789602729.png

See if this helps

 

sevenhills_0-1635789520440.png

 

@sevenhills 

Hi, 

Thank you for your proposed solution but I need the count of products finished that is within the manager's respective schedule. 

markefrody_1-1635791850678.png


I have tried your proposed solution. It does not differentiate how many products where finished by each manager during the day. It shows the same count of products for Manager A and B for that day.

markefrody_2-1635791968134.png

 

 

My bad, I misunderstood.
I kept the same changes mentioned above and added a new measure and created new visual. Please see if this helps

 

a) Created a measure part of manager schedule

 

Prod Count = 

var _d1 = Minx('Manager Schedule', 'Manager Schedule'[Start Time])
var _d2 = Minx('Manager Schedule', 'Manager Schedule'[Clock Out])
var _Prod_count = CALCULATE( COUNTROWS('Production Schedule'), FILTER('Production Schedule', 'Production Schedule'[Date Finished] >= _d1 && 'Production Schedule'[Date Finished] <= _d2))

return _Prod_count

 

 

sevenhills_0-1635794196338.pngsevenhills_1-1635794214120.png

 

 

 

@sevenhills 
Hi,

Thank you for the revision. It seems the total per day for 9/27/2021 is not the same as the calculated measure.

Product Count
markefrody_1-1635802644647.png

Calculated Measure

markefrody_2-1635802887432.png

 




I think what I provided is correct.

 

Let me say why, In your product count grid, it is not counting empty (string) Produc ID. All these are part of the manager 2 schedule when you verify the data and are on 9/27. You can check the data tab.  You have empty Produc ID in your data.

 

In your Product Count visualization table, you are using default summarization by power bi and it takes only non empty Produc ID. 

 

You can verify using to match the counts:

Measure 3 = CountRows('Production Schedule')
 
What I used is CountRows in my formula! 
 
Tune to your requirements whether you want the empty Produc IDs or not!

 

sevenhills_1-1635805121565.png

 

@sevenhills 
Sorry about that. Thank you for letting me know that there are empty fields on the data. 

Thank you for helping me. It's working perfectly. 


Best regards,
Mark V.

@markefrody 

 

Glad it is working. 

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.