Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Counting multiple date columns

Hello all,   I'm using PowerBI Desktop and trying to generate an Clustered Column Chart from a CSV file that I receive from an external company. The CSV looks like:   ID DateAdd LastModifie...
  • v-eachen-msft's avatar
    6 years ago

    Hi Anonymous ,

     

    At first, you need to create a calendar table as a slicer.

    Calendar =
    CALENDAR ( MIN ( 'Table'[DateAdd] ), MAX ( 'Table'[LastModified] ) )

    Then create two new measures to get counts.

    Count1 =
    VAR minselect =
        CALCULATE ( MIN ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) )
    VAR maxselect =
        CALCULATE ( MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) )
    RETURN
        COUNTROWS (
            FILTER (
                'Table',
                'Table'[DateAdd] >= minselect
                    && 'Table'[DateAdd] <= maxselect
            )
        )
    Count2 =
    VAR minselect =
        CALCULATE ( MIN ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) )
    VAR maxselect =
        CALCULATE ( MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) )
    RETURN
        COUNTROWS (
            FILTER (
                'Table',
                'Table'[LastModified] >= minselect
                    && 'Table'[LastModified] <= maxselect
                    && 'Table'[CurrentStatus] = "Closed"
            )
        )

    Here is the result.

    I uploaded my test file as a attachment, you can download and refer to it.