Forum Discussion

KatkaS's avatar
KatkaS
Icon for Post Patron rankPost Patron
5 years ago
Solved

Exclude blanks

Hello could anyone please hlep me with following? I have calculated column of days excluding week-ends, which is working fine if Approved date and Closed Date are defined, but not if they are blank...
  • jdbuchanan71's avatar
    jdbuchanan71
    5 years ago

    Try something like this.

     

    Avg Days =
    CALCULATE (
        AVERAGE ( 'Report'[# Days] ),
        'Report'[# Days] <> 0
    )

     

    Or you could change the [# Days] to return blank instead of 0 which will not get counted in an average.

     

    # Days =
    IF (
        ISBLANK ( 'Report'[Approved Date] ) || ISBLANK ( 'Report'[Closed Date] ),
        BLANK(),
        CALCULATE (
            SUM ( 'CALENDAR'[Day] ),
            DATESBETWEEN (
                'CALENDAR'[Date],
                'Report'[Approved Date],
                'Report'[Closed Date]
            )
        )
    )