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
jusTodd
Advocate III
Advocate III

Combined Count Based on Different Dates in Different Tables

I am looking to get a count of items in TableA based on the date in TableA and a total count of items in TableA and TableB, based a different date in TableB.

 

Looking for a little feedback, since I work in silo and am only about 6 months in with PowerBI.  I would like to know if this can be achieved in DAX, or if the Append Query I created is really for the best.  It certainly seems the easiest solution.

 

(EDIT - The biggest problem with the current solution is filtering based on another column that identifies Scheduled Maintenance.  At this time, I have to add the column to the filter 3x on one page ... am hoping a little proper DAX can solve that issue).

 

 

The two tables, 'OpenWOs' and 'ClosedWOs' of which I need a count of

1) Open work orders by the month in which they were created

2) Closed work orders by the month in which they were closed

3) Created work orders by the month in which they were created

 

The tables are joined to a calendar table to facilitate a rolling 12 months in the visualizations.

 

OpenWOs is joined by [Date Created] and ClosedWOs is joined by [Date Completed], which gives me a proper count of exactly when the Opens were created and Closed were completed.

 

The problem lies with getting the count for all  WOs created in the month they were created, since I have ClosedWOs joined by [Date Completed].  Obviously, it won't work if I join by [Date Created] either.

 

Consequently, I created an Append Query to pull the Created Dates and Closed Dates from their respective tables into one to overcome this challenge, and because I simply could not figure out proper DAX for the situation.  That table 'CreatedWOs' is also joined to the calendar table and everything gives me the exact numbers that I expect.

 

The following image shows the results I am after, which show Created WOs in the month they were created, Open WOs from they were created, and Closed WOs in the month they were closed.

 

snap.jpg

 

The following are sample data and a snapshot of the model. 

 

Open WOs

WO IDStatusDate Created
1690Open7/19/2022
2002Open9/1/2022
2003Open9/1/2022
2068Open9/21/2022
2069Open9/21/2022
2070Open9/21/2022
2071Open9/21/2022
2072Open9/21/2022
2073Open9/21/2022

 

Closed WOs

WO IDStatusDate CreatedDate Complete
92Closed, Completed9/21/20211/5/2023
451Closed, Incomplete7/19/20221/24/2023
750Closed, Incomplete9/1/20221/25/2023
786Closed, Completed2/20/2022 1/6/2023
874Closed, Completed3/3/20221/19/2023
994Closed, Incomplete9/21/20221/24/2023
1276Closed, Completed5/18/20221/3/2023
1482Closed, Completed6/15/20221/25/2023

 

 

model.jpg

 

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@jusTodd , Closed WOs contain created as well as the closed date that should work for both open and close, You should bring a table having Created date, closed date, and null if open

 

or append the table Open WOs & Closed WOs in power query and then this approach will work

Power BI: HR Analytics - Employees as on Date : https://youtu.be/e6Y-l_JtCq4
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

 

Thanks for the response.  That is exactly what I have done so far.  Getting past having the filter from each table for the same field seems the biggest challenge just now.

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.