cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sach18 Helper III
Helper III

Not getting the YTD of previous year using measures

my previous year measure is showing wrong value. Can anyone help with this ?

 

cytd = TOTALYTD(SUM(FinalTable[Value]),FinalTable[Date],FinalTable[Date]<=TODAY(),"12/31")
 
pytd =
CALCULATE ( [cytd], SAMEPERIODLASTYEAR ( FinalTable[Date]), FILTER ( ALL ( FinalTable ), FinalTable[Date] <= DATE(YEAR(TODAY()) -1 , [Maximum], 1)))

Maximum =CALCULATE ( MAX( FinalTable[MonthNumber]), FILTER ( ALLSELECTED ( FinalTable), FinalTable[Value] <> BLANK ()
&& FinalTable[YearNumber] = [year selected] ))


Note: I am not using Date table as I need the filter slicers as shown in below screenshot.

cytd.JPG

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: Not getting the YTD of previous year using measures

HI @sach18,

I'd like to suggest you to use date function to define filter range to calculate, it is hard to custom and accuracy control the nested calculation of time intelligence functions.

Time Intelligence "The Hard Way" (TITHW)  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI

View solution in original post

4 REPLIES 4
sach18 Helper III
Helper III

Re: Not getting the YTD of previous year using measures

Hi @v-huizhn-msft 
I have seen similar post in the below link.
https://community.powerbi.com/t5/Desktop/How-to-display-sales-YTD-and-sales-last-YTD-over-years/td-p...

Mine is similar issue but On check of the year number in slicer i need to calculate YTD and also Previous year YTD.
Your suggestions will be helpfull. 

I need this quick so I have tagged you. Anyone else who can help me with this will be great. Thanks in Advance.

Community Support
Community Support

Re: Not getting the YTD of previous year using measures

HI @sach18,

I'd like to suggest you to use date function to define filter range to calculate, it is hard to custom and accuracy control the nested calculation of time intelligence functions.

Time Intelligence "The Hard Way" (TITHW)  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI

View solution in original post

sach18 Helper III
Helper III

Re: Not getting the YTD of previous year using measures

Hi @v-shex-msft ,

First of all, Thanks for the ref link which is helping me. But when I am trying it. I get the below visual error. Can you help me with that ?
Is there any other formula for LYTD ?
Checking on 2020 is fine. But when checking on other years give me error.
2020.JPG
2019.JPG

 

 I have the same measures 

TI_TotalYTD = TOTALYTD(SUM(FinalTable[Value]), DateTable[Date])
TI_TotalLYTD = CALCULATE([TI_TotalYTD],SAMEPERIODLASTYEAR(DateTable[Date]))

Relations in model is as follows
relation1.JPG

 

relation2.JPG

 

Relation for FinalTable and DateTable is Many to one with Both Corss filtering.

Let me know where is my issue.
Highlighted
sach18 Helper III
Helper III

Re: Not getting the YTD of previous year using measures

Thanks @v-shex-msft ,

Your suggestion helped me. For the above issue, i have changed the relation of cross filter for DateTable and FinalTable Date column to Single.

Happy to learn Power bi.

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors