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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Sum of Prior 6 Months based on two dates in same table

I have a table of producton order numbers that includes two dates:  production order date and defect detection date.  I need to calculate the prior 6 months of defects from the previous 6 months of production orders, for each month in a calendar year.  So the attached example below shows just a matrix of the months of production on the rows, and months of defect detection on the columns.  

 

The corresponding result for September would be 3,178 (Apr-Sep).  Which is the prior 6 months of production and the number of defects in that same period.  So for example in the table for month detected "9" and production order "9", that intersection shows a value of 11...meaning 11 defects detected for production orders created in September.  

 

I have not been able to recreate the results utilizing a DAX calculation.   I have tried DATESBETWEEN, DATESINPERIOD.  I have a date table, which has two relationships with my production order table.  Active with the Production Order date, and inactive with the Defect Detection date.  And I have used different combinations of this as well.  I'm looking for help on wha the proper calculation would be.

 

Probably not explaining this well enough, but hopefully this is enough to go on.

 

 Month of Defect Detection 
.         
Month of Production123456789Grand Total
12116318011210949965425809
2 2810210111540359649566
3  161811547710654204792
4   151891962359169795
5    3817535726792929
6     40265295119719
7      21287192500
8       27197224
9        1111
3 REPLIES 3
sturlaws
Resident Rockstar
Resident Rockstar

Hi, @Anonymous,

 

could you provide a sample report/dataset?

 

cheers,

Anonymous
Not applicable

I wasn't sure how to attach a table properly, but it boils down to three columns: 1) Production Order Date, 2) Defect Detection Date, 3) Defect Qty  

 

There is also a date table, that is just the full date.  I haven't created any additional columns for month, year, etc...

 

Below is a representation of the data, and expected results on the right hand side corresponding to the highlight areas.  For each month, it looks back at the previous 6 months of production time, and detection time, and sums the quantity of defects.  

 

 

Sample Data_pivot.JPG

sturlaws
Resident Rockstar
Resident Rockstar

Hi, @Anonymous,

 

could you provide a sample report/dataset?

 

cheers,

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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