Forum Discussion
Ignoring Relationships
Hi,
Having a bit of difficulty nailing down a formula and hoping for some help.
I have three tables in a relationship:
Case - Represents a case of work
Report - Represents reports associate with cases
Date - Date Dim
I'm trying to show how many reports have been completed on each closed case and continually falling short.
My data looks like the below; Date is a standard date dimension with multiple columns i.e. Date and MonthYear (MMM-YY). Case links to Report and Date with active relationships; Report links to date with inactive relationships.
Case
| ID | OpenCase | ClosureDate |
| 123 | 22/01/2019 | |
| 456 | 1 | |
| 789 | 24/01/2019 |
Report
| ID | CaseID | Completed | CompletedDate |
| 1 | 123 | 1 | 01/01/2019 |
| 2 | 123 | 1 | 05/04/2012 |
| 3 | 123 | 1 | 03/01/2019 |
| 4 | 456 | 1 | 04/01/2019 |
| 5 | 456 | ||
| 6 | 789 | 1 | 01/01/2019 |
According to the above, I know that 2 cases closed in Jan-19; I can prove this with
CasesCount = DISTINCTCOUNT('Case'[ID])
closedCases = CALCULATE([CasesCount], ISBLANK('Case'[OpenCase]))
I then want to find the number of reports associated with that case; I don't care when they were completed, I just need to know that they exist on that specific case.
When I look at the case level I get the right answer but once a date value is brought in, the figures are wrong and I'm shown closed cases (correct) but reports filed in that period (incorrect), my question is how can I ignore any date relationships with Reports and show a count of reports for all cases closed in that period.
I would expect to see something like the below but instead I'm seeing 3 reports because one of those was completed in a different month.
| MonthYear | Cases Closed | Reports |
| Jan-19 | 2 | 4 |
Most recently I've tried this but returning blank; I'm trying to say return the count of reports for any cases that closed during the time period.
start = MIN(Dates[Date]) end = MAX(Dates[Date])
reports = DISTINCTCOUNT(Reports[ID]) closedCasesReports = CALCULATE([reports], FILTER('Case', 'Case'[ClosureDate] >= [start] && 'Case'[ClosureDate] <= [end] ) )
I've tried quite a lot of iterations with varying success but it appears that whenever the date is brought into the equation results return incorrectly... Can I ignore a date relationship altogether?
Any help greatly appreciated.
BM4291 here is updated pbix, added another case without report and showing some calculations, not sure if that is what you are looking for.
10 Replies
- BM4291Resolver I
parry2k - Yes, I was definitely overcomplicating... This gets me my base measure.
The next challenge was pointing out where a case has atleast one report but keep coming unstuck or getting blank values... Any suggestions.
I've tried a few variations of CALCULATE and FILTER but the results are coming back far too high; is it because I need to repeat all of the additional conditions I have?