Forum Discussion

powerbi92614's avatar
powerbi92614
New Member
7 years ago
Solved

I need help creating a YTD count measure

I can't believe I'm stuck on such a simple task. I have a table that contains data from 2018 to now. Basically, I need a measure to count the total number of rows for 2018.   I used this measure an...
  • jdbuchanan71's avatar
    jdbuchanan71
    7 years ago

    powerbi92614 , give this one a try.  It forces the date range to be the full prior year.

     

    PY YTD = 
    VAR MaxDate = MAX ( 'Escalation Log'[Date Received] )
    VAR PYStart = DATE ( YEAR ( MaxDate ) -1, 1, 1 )
    VAR PYEnd = DATE ( YEAR ( MaxDate ) -1, 12, 31 )
    RETURN
    CALCULATE (
        COUNT ( 'Escalation Log'[Date Received] ),
        DATESBETWEEN ( 'Escalation Log'[Date Received], PYStart, PYEnd )
    )