Hello to you all, I hope you can help me with a calculation I’m stucked in.
I want to calculate the sum of days a project is open depending on other columns at the time the user can select in a slicer.
Therefore I have two tables. A date table and a fact table. Both are connected via several inactive connectors (created, performed), an one active connector (closed).
In my fact table there are columns for ID, cost unit, created, performend, and closed.
The goal is as follows:
The User selects a Month in Year in a slicer (dates table).
Task: how many days a cost unit/ID is open - calculated to the chosen month (slicer)
Calculation:
Start date:
- column “created”
End date:
-
when column “performed” is in the chosen month (slicer), than column “performed”
-
when column “perfomed” is blank and column “closed” is in the chosen month (slicer), than column “closed”
-
when column “perfomed” and column “closed” are blank, than End of Month of the chosen month (slicer)
So far I tried the code below.
Overdue closed in days =
CALCULATE(
SUMX(
SUMMARIZE('crm Tätigkeit_BI', 'crm Tätigkeit_BI'[created], 'crm Tätigkeit_BI'[performend], 'crm Tätigkeit_BI'[closed], "End of Month", ENDOFMONTH(Dates[Date]),
"DaysBetween", IF(
MONTH('crm Tätigkeit_BI'[performend]) = MONTH(SELECTEDVALUE(Dates[Date])),
DATEDIFF('crm Tätigkeit_BI'[created], 'crm Tätigkeit_BI'[performend], DAY),
IF(
MONTH('crm Tätigkeit_BI'[closed]) = MONTH(SELECTEDVALUE(Dates[Date])),
DATEDIFF('crm Tätigkeit_BI'[created], 'crm Tätigkeit_BI'[closed], DAY),
DATEDIFF('crm Tätigkeit_BI'[created], ENDOFMONTH(Dates[Date]), DAY)))
),[DaysBetween]),
USERELATIONSHIP(Dates[Date], 'crm Tätigkeit_BI'[created] ) -- relationship needs to be set on calculated column "End of Month" -> cause we want to know, how many days the cost unit is not closed to the End of Month (chosen month in slicer)
)
Unfortunately I’m not able to set the relationship from a “real” column in a table to the calculated column “End of Month”. But without, the calculation delivers the wrong numbers.
Do you have any ideas how to solve this.