Forum Discussion

sabilahmed's avatar
sabilahmed
Resolver I
3 years ago

Previous Year YTD (Cluster Column Chart)

My PY Encounters is showing the total (JAN - DEC) value for all months in cluster column chart:

 

 

I need it to show the correct amount per month

 

here is the DAX:

 

Encounters_PY = 
    CALCULATE(
        [Encounters],
        FILTER(
            ALL('Date - Service'),
            YEAR('Date - Service'[CalendarDate])
            = YEAR(
                MAX( 'Date - Service'[CalendarDate])
                    )-1
    ),
    ALL ( Scenario[Description] )
)

 

Can anyone please help me? Thanks in advance.

1 Reply

  • sabilahmed , You need to use date table joined with date of your table

     

    YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
    Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

     

    or

     

    YTD =
    var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , MAXX(allselecetd('Date'), 'Date'[Date]))
    var _min = eomonth(_max,-1*MONTH(_max))+1
    return
    CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

    LYTD =
    var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , MAXX(allselecetd('Date'), 'Date'[Date]))
    var _max = Date(Year(_max1)-1, Month(_max1), Day(_max1))
    var _min = eomonth(_max,-1*MONTH(_max))+1
    return
    CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

     

     

    Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
    Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

     

    If this does not help
    Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.