Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

distributing duration across month.

I need a matrix to calculate the number of working days per person & per month. I've used the method in this video,https://www.youtube.com/watch?v=R8tDKwimSsY. But the result is not what I'm looking...
  • AllisonKennedy's avatar
    AllisonKennedy
    6 years ago
    The SELECTEDVALUE is not needed and will mess up the formula if you leave it in, so try:

    Dist =

    VAR _MinDate = FIRSTDATE(Dates[Date])
    VAR _MaxDate = LASTDATE(Dates[Date])

    RETURN
    SUMX('data 1',
    VAR _Start = 'data 1'[Date From]
    VAR _End = 'data 1'[Date To]

    RETURN
    IF(
    (_End<=_MaxDate && _End>=_MinDate)
    || (_Start>=_MinDate && _Start<=_MaxDate)
    ,

    DATEDIFF(MAX(_Start, _MinDate), MIN(_End, _MaxDate),DAY)
    )
    )