cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sabilahmed
Resolver I
Resolver I

Previous Year YTD (Cluster Column Chart)

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

 

sabilahmed_0-1665479067560.png

 

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 1
amitchandak
Super User
Super User

@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.

Helpful resources

Announcements
Vote for T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!