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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Pandadev
Post Prodigy
Post Prodigy

I am trying to get a measure to work to compare the date with same day and month in 2019

I have this measure that works , but is there a better solution to make it more dynamic please , 

Aircraft Tracked 2019 = CALCULATE([Aircraft Tracked], UNION(
DATEADD(SUMMARIZE(FILTER('Arrival Date UTC', 'Arrival Date UTC'[Arrival Year]=2018), 'Arrival Date UTC'[Arrival Date UTC]), 365, DAY),
SUMMARIZE(FILTER('Arrival Date UTC', 'Arrival Date UTC'[Arrival Year]=2019), 'Arrival Date UTC'[Arrival Date UTC]),
DATEADD(SUMMARIZE(FILTER('Arrival Date UTC', 'Arrival Date UTC'[Arrival Year]=2020), 'Arrival Date UTC'[Arrival Date UTC]), -366, DAY),
DATEADD(SUMMARIZE(FILTER('Arrival Date UTC', 'Arrival Date UTC'[Arrival Year]=2021), 'Arrival Date UTC'[Arrival Date UTC]), -731, DAY),  // 2020 is a leap year, hence -366 for 2020 adjustments, and an additional -365 for 2021 adjustments
DATEADD(SUMMARIZE(FILTER('Arrival Date UTC', 'Arrival Date UTC'[Arrival Year]=2022), 'Arrival Date UTC'[Arrival Date UTC]), -1096, DAY), // 2020 leap year included in previous adjustment, so -365 * 3 for 2019 to 2022
DATEADD(SUMMARIZE(FILTER('Arrival Date UTC', 'Arrival Date UTC'[Arrival Year]=2023), 'Arrival Date UTC'[Arrival Date UTC]), -1461, DAY), // Includes leap year 2020, so -365 * 4 for 2019 to 2023
DATEADD(SUMMARIZE(FILTER('Arrival Date UTC', 'Arrival Date UTC'[Arrival Year]=2024), 'Arrival Date UTC'[Arrival Date UTC]), -1826, DAY) // Includes leap years 2020 and 2024, hence -366 (for 2020) + -365 * 4 (for other years) = -1826

))
2 REPLIES 2
Pandadev
Post Prodigy
Post Prodigy

Thanks , I need it to be exact match , my flight table is just in date format and has a many to one relationship with the Arrival Date UTC Date Table I created , what I need is to match every date to the same month and day in 2019 , so if date is 01/02/2023 , then comapre values for 01/02/2019

amitchandak
Super User
Super User

@Pandadev , Usually all these work when Date of your table(Only date, no timestamp) joins with the date of the date table, and you columns from that date table in measures, visuals and slicers

 

example

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))
week Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-364,DAY))

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.