Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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
v-shex-msft
Community Support
Community Support

HI @Anonymous,

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
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

HI @Anonymous,

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
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

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.
Anonymous
Not applicable

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.

Anonymous
Not applicable

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.