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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
GWTF
Helper I
Helper I

Comparing rolling years....?

Hi all,

Yeah, even a good subject decription was hard...

 

I'm running into the boundaries of my limited Power BI capabilities 😁 AKA: I need help!!

 

I'm trying to create a measure that gives me the possibility to compare the total amount of registered incidents in a "running" 1-year period. In a way that by selecting a random date (let's say the 12th of May 2022) the total of that running year (values ranging from the 12th of May 2021 till the 12th of May 2022) are compared with the totals of previous running years (12-05-2020 to 12-05-2021 AND 12-05-2019 to 12-05-2020, etc.).

 

I cannot wrap my head around it.

 

I have a date-table (in Dutch):

Datum = ADDCOLUMNS ( CALENDAR (DATE(2018, 1, 1), DATE(2039,12,31)),

"DatumInteger", FORMAT ([Date], "YYYYMMDD" ),

"Jaar", YEAR ([Date]),

"Kwartaal", QUARTER ([Date]),

"Maandnummer", FORMAT ([Date], "MM" ),

"JaarMaandNummer", FORMAT ([Date], "YYYY/MM" ),

"JaarMaandkort", FORMAT ([Date], "YYYY/mmm" ),

"Maandnaamkort", FORMAT ([Date], "mmm" ),

"Maandnaamlang", FORMAT ([Date], "mmmm" ))

 

And a table with incidents:

Incident_dateYearMonthIncident_ID
17-3-201820183U61878
18-4-201820184U62535
23-7-201820187U64294
1-8-201820188U64476
4-8-201820188U64537
8-8-201820188U64609
17-8-201820188U65010
20-8-201820188U65013
23-8-201820188U65090
7-9-201820189U86699
13-9-201820189U86763
9-4-201920194U123774
19-4-201920194U123953
24-4-201920194U123988
25-4-201920194U124015
14-5-201920195U124301
1-7-201920197U124981
14-8-201920198U125771
10-2-202020202U128336
24-2-202020202U128572
6-3-202020203U128808
9-3-202020203U128842
29-6-202020206U130464
24-9-202020209U131509
6-10-2020202010U131626
6-3-202120213U133552
16-12-202120211231280
16-12-202120211231637
20-12-202120211233113
17-1-20222022137908
24-1-20222022139580
3-2-20222022242963
7-2-20222022243327
1-3-20222022338947
4-3-20222022349552
22-3-20222022350820
25-3-20222022353646
30-3-20222022354375
5-4-20222022455017

 

Any assistance would be highly appreciated!

 

Kind regards,

Wilco

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @GWTF ,

 

You could refer below formulas.

_YTD =
CALCULATE (
    SUM ( Incidents_table[amount] ),
    FILTER (
        ALLSELECTED ( Incidents_table ),
        Incidents_table[Incident_date]
            > EDATE ( SELECTEDVALUE ( Incidents_table[Incident_date] ), -12 )
            && Incidents_table[Incident_date]
                <= SELECTEDVALUE ( Incidents_table[Incident_date] )
    )
)
P_YTD =
CALCULATE (
    SUM ( Incidents_table[amount] ),
    FILTER (
        ALLSELECTED ( Incidents_table ),
        Incidents_table[Incident_date]
            > EDATE ( SELECTEDVALUE ( Incidents_table[Incident_date] ), -24 )
            && Incidents_table[Incident_date]
                <= EDATE ( SELECTEDVALUE ( Incidents_table[Incident_date] ), -12 )
    )
)

 

Best Regards,

Jay

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @GWTF ,

 

You could refer below formulas.

_YTD =
CALCULATE (
    SUM ( Incidents_table[amount] ),
    FILTER (
        ALLSELECTED ( Incidents_table ),
        Incidents_table[Incident_date]
            > EDATE ( SELECTEDVALUE ( Incidents_table[Incident_date] ), -12 )
            && Incidents_table[Incident_date]
                <= SELECTEDVALUE ( Incidents_table[Incident_date] )
    )
)
P_YTD =
CALCULATE (
    SUM ( Incidents_table[amount] ),
    FILTER (
        ALLSELECTED ( Incidents_table ),
        Incidents_table[Incident_date]
            > EDATE ( SELECTEDVALUE ( Incidents_table[Incident_date] ), -24 )
            && Incidents_table[Incident_date]
                <= EDATE ( SELECTEDVALUE ( Incidents_table[Incident_date] ), -12 )
    )
)

 

Best Regards,

Jay

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors