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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Previous Year To Date

Hi

 

I've asked the question before and it got solved. I'm not replicating the solutions and I can't get it to work.

 

I have a sales table with sales recorded from 01/01/2022 to 01/04/2023. I've created a data table with the same range and created a relation between the 2.

 

I can pull off current year sales not a problem. When I try to create previous year sales it's totalling the full month of april last year as well when it should be 01/01/2022..01/04/2022

 

Lewis_S_William_0-1706546762076.png

 

It should be 84k but it's returning 120k.

 

I've tried the following

 

 
Sales PY (£) =
    CALCULATE(SUM(SalesDashboard[SalesAmountActual]),SAMEPERIODLASTYEAR('Date'[Date]))
YTD LY (limited by last date in Data table) =
VAR DataMaxDate =
    CALCULATE ( MAX ( 'Date'[Date] ), ALL ( SalesDashboard ) )
RETURN
    CALCULATE (
        [YTD],
        SAMEPERIODLASTYEAR (
            INTERSECT (
                VALUES ( 'Date'[Date] ),
                DATESBETWEEN ( 'Date'[Date], BLANK (), DataMaxDate )
            )
        )
    )

Any suggestions?

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@Anonymous Try Better Year to Date: Better Year to Date Total - Microsoft Fabric Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Daniel29195
Super User
Super User

@Anonymous 

Please try this modified version : 


YTD LY (limited by last date in Data table) =
VAR DataMaxDate =
    CALCULATE ( MAX ( 'Date'[Date] ), ALL ( SalesDashboard ) )
RETURN
    CALCULATE (
        [YTD],
        SAMEPERIODLASTYEAR (datesytd('Date'[Date])), all(dimdate[Date])
)
        
   

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution !

It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.