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
smithkj1
Frequent Visitor

Count complaints received by month, of those, how many were produced last 3 months?

I have a table which contains conumser complaints. the table has complaint received date and this is linked to the date when the product was made - [production date]. 

I need to calculate the number of complaints received by month  and of those recieved in a given month, I need to calculate how many of the products were produced in the last 3 months. For example, I need complaints recieved in January, and of those complaints a count of the products which were produced in November, December and January. E.g complaints received in January might be 50, and of those 50, 30 might have been produced in Nov, Dec, January. 

In addition to the data table, i have created a calendar table. 

 

I'm going around in circles! testing dateadd, datesbewteen, datesinperiod - but I'm getting nowhere. 

I need this analysis for last 4 years. 

Many thanks in advance if you cna help! 

 

1 ACCEPTED SOLUTION

I don't have your sample so I can't really test but, an idea would to harvest the min and max dates:


BeginDate = DATE(YEAR(Sheet1[Initial Receipt Date]), MONTH(Sheet1[Initial Receipt Date]) -3, "1")

 

 

EndDate = EOMONTH(Sheet1[Initial Receipt Date], -1)

 

From there, most likely you can use datesinbetween to get the count:

 

Count Complaints= 
var var_Start = MAX(Sheet1[BeginDate])
var var_End = MAX(Sheet1[EndDate])
Return
CALCULATE(COUNT(Sheet1[Complaint Metric]), DATESBETWEEN(DateTable[Date], var_Start, var_End))


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

6 REPLIES 6
SaumyaShetty
Frequent Visitor

Please post a workbook with some dummy data so that people can help you out.

HI - thanks so much for your reply - I don't get an option to insert a file. I hope this is enough?

Internal Case IdInitial Receipt DateComplaint MetricManufacturing DateManufacturing Line
12/2/2018110/24/20171
22/2/2018112/21/20171
32/2/2018112/7/20171
42/3/2018112/5/20171
52/3/201811/24/20181
62/3/2018112/3/20171
72/4/201811/21/20181
82/4/201811/21/20181
92/4/2018112/5/20171
102/4/2018111/20/20172
112/4/2018112/28/20172
122/4/201817/26/20172
132/4/201815/9/20152
142/5/201818/17/20172
152/5/201811/13/20182
162/5/201811/3/20182
172/5/201811/3/20183
182/5/2018112/22/20173
192/5/201811/11/20183
202/5/2018112/17/20173

so in this picture - the top visual is complaints received date. bottom visual is by manufactured date. 

so when i select complaints received in December (=211), I can see the total productus manufactured in OND was (68+46+11)

I want a table which shows this by month, without having to manually select different filters - i should just see the data by month. 

dummydata.PNG

I don't have your sample so I can't really test but, an idea would to harvest the min and max dates:


BeginDate = DATE(YEAR(Sheet1[Initial Receipt Date]), MONTH(Sheet1[Initial Receipt Date]) -3, "1")

 

 

EndDate = EOMONTH(Sheet1[Initial Receipt Date], -1)

 

From there, most likely you can use datesinbetween to get the count:

 

Count Complaints= 
var var_Start = MAX(Sheet1[BeginDate])
var var_End = MAX(Sheet1[EndDate])
Return
CALCULATE(COUNT(Sheet1[Complaint Metric]), DATESBETWEEN(DateTable[Date], var_Start, var_End))


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Hi - i have another question. I have a measure which calcs complaints received and I can show this data in a matrix, per month. 

I use the datesbetween to calculate the number of complaints produced last 3 months.  I have a calendar table - I have an active relationship with complaint receipt date and an inactive relationship with production date.

 

Count Complaints L3M =
var var_Start = MAX('Data'[BeginDate])
var var_End = MAX('Data'[EndDate])
Return
CALCULATE(sum('Data'[Complaint Metric]), USERELATIONSHIP('Calendar'[Date], 'Data'[ProductionDate]),DATESBETWEEN('Calendar'[Date], var_Start, var_End))
 
this is what I need to calculate - for a given month, the number of complaints received (no problem - the first measure gives me that) but of those received, how many were produced in the 3 months previously. 
For example, I need to see on a table, by month, the number of complaints received, and then by month, Of those complaints received in that month, how many were produced in the 3 months previously. so for January, I have a total complaints received in January and of those received in january, how many were produced in Nov, Dec, January. 
So received in January might be 200, Produced last 3 months might be 150 (meaning of 200 complaints recieved, 150 were produced in Nov, Dec, Jan). What my current measure gives me is the total produced in Nov, Dec, Jan - i.e. doesn't take into account whether the complaint was received in january or not. 
 
I hope it makes sense!! 
thanks in advance

thanks so much - in Begindate - I used -2 rather than -3 (this gave me the date range I needed for each month).

otherwise, this works perfectly. I now have the data I need. Thanks so much for your help!!

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.

Top Solution Authors