Forum Discussion

SamFletch's avatar
SamFletch
Icon for Helper I rankHelper I
5 years ago
Solved

Calculating Days Based On Dates & Criteria

Hello all, I've been scratching my head with a problem for a few days now and I just can't seem to figure it out, so I was hoping you could help.   I'm trying to calculate how many days there are b...
  • Fowmy's avatar
    5 years ago

    SamFletch 

    Add the following code as a new column to your table. Check with other scenarios and reply with your findings.

    Days Active This Month = 
    var _thismonth = (EOMONTH(TODAY(),0))
    var _active = T3[Is Active] = "Yes"
    return
    IF(
        _active,
       Min(MIN( _thismonth - T3[Activate Date] + 1 , _thismonth ), DAY(_thismonth)),
       Max(0,T3[Deactivate Date] - (_thismonth - DAY(_thismonth)) )   
    )