I have a fact table (Cases) similar to this one:
> Case Number Date Opened Date Closed Status
> C123564659 06/11/2019 07/11/2019 Closed
> C123564656 06/11/2019 07/11/2019 Closed
> C123564660 07/11/2019 07/11/2019 Closed
> C123564655 07/11/2019 11/11/2019 Closed
> C123564654 07/11/2019 11/11/2019 Closed
> C123564657 07/11/2019 12/11/2019 Closed
> C123564658 07/11/2019 14/11/2019 Closed
It is related to a date table (Calendar) via the "Date Opened" column.
I need to count the number of closed cases by day, that will be displayed in both a Matrix Table (where Rows = days) and Column Chart (where the X axis = days or weeks) visualizations.
If I do a simple count like:
CALCULATE(COUNT(Cases[Case Number]); Cases[Status] = Closed)
Then I just get the total amount of closed cases that match the "Date Opened" for a certain day. For example, according to the table above, I would get a total of 5 closed cases on 07/11/2019, because of the date relationship is taking only the "Date Opened" column into account to calculate the dates.
If I create a VAR to define the selected date such as:
VAR openedDate = SELECTEDVALUE(DIM_CALENDAR[Date])
RETURN
CALCULATE(COUNT(Cases[Case Number]); Cases[Status] = Closed; openedDate = Cases[Date Closed])
Then I will only get 1 closed case, because it is the only "Date Closed" that matches the "Date Opened".
So I need a way to show the actual number of cases closed in a certain day - which would be 3 cases (following the same example on 07/11/2019)
Any ideas?
Thank you in advance for your time.
EDIT:
I think I found the solution. I've created a DAX summarized Table with only closed cases, then I established all the relevant relationships to the DIM tables, including the Calendar table.
It seems to be working, but I would still like to hear if anyone has a better solution.
Thank you.