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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
NewbieJono
Post Partisan
Post Partisan

Year to date comparison

Hello, sorry i previously had help ont his but I'm not getting the result I am expecting.

 

could anyone help with example DAX.

 

i need to compare volumes of YTD april 1st to current date.

 

but I need to compare to the past 5 years of the same period.

 

e.g Today would show

 

01/04/2024 - 18/04/2024

01/04/2023 - 18/04/2023

01/04/2022 - 18/04/2022

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @NewbieJono 

 

Thanks for the reply from @Greg_Deckler , please allow me to provide another insight:

 

I created a sample to get the difference in Value for 01/04/2024 - 19/04/2024 and the difference in Value for 01/04/2023 - 19/04/2023, hope this helps.

 

My sample:

vxuxinyimsft_0-1713516559539.png

 

Create two measures as follow

 

01/04/2024 - today = 
VAR _1 = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Date] = EOMONTH(TODAY(), -1) + 1))
VAR _2 = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Date] = TODAY()))
RETURN
_1 - _2

 

 

 

01/04/2023 - 19/04/2023 = 
VAR _11 = DATE(YEAR(TODAY()) - 1, MONTH(TODAY()), DAY(TODAY()))
VAR _1 = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Date] = _11))
VAR _2 = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Date] = EOMONTH(_11, -1) + 1))
RETURN
_1 - _2

 

 

Result:

vxuxinyimsft_1-1713516706615.png

 

If this sample data is structurally different from the one you are using, please do not hesitate to mention it and I will modify it.

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @NewbieJono 

 

Thanks for the reply from @Greg_Deckler , please allow me to provide another insight:

 

I created a sample to get the difference in Value for 01/04/2024 - 19/04/2024 and the difference in Value for 01/04/2023 - 19/04/2023, hope this helps.

 

My sample:

vxuxinyimsft_0-1713516559539.png

 

Create two measures as follow

 

01/04/2024 - today = 
VAR _1 = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Date] = EOMONTH(TODAY(), -1) + 1))
VAR _2 = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Date] = TODAY()))
RETURN
_1 - _2

 

 

 

01/04/2023 - 19/04/2023 = 
VAR _11 = DATE(YEAR(TODAY()) - 1, MONTH(TODAY()), DAY(TODAY()))
VAR _1 = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Date] = _11))
VAR _2 = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Date] = EOMONTH(_11, -1) + 1))
RETURN
_1 - _2

 

 

Result:

vxuxinyimsft_1-1713516706615.png

 

If this sample data is structurally different from the one you are using, please do not hesitate to mention it and I will modify it.

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Community Champion
Community Champion

@NewbieJono You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

 

Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



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

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.