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

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

1 REPLY 1
v-jayw-msft
Community Support
Community Support

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

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.

Top Solution Authors