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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Syndicate_Admin
Administrator
Administrator

YTD calculation for non-consecutive years

Good afternoon

I would need your help related to a YTD calculation.

I have a table called: COMPLETE D_PEDIDO where the fields are:

-ENTRY ORDERS EUROS

-CREATION DATE

and another table M_CALENDARIO where the DAY field is (which is linked to CREATION DATE)

I have data from 2019 and 2023 and I want to compare the YTD of 2019 with the YTD of 2023 month by month.

Let's say today is 03/28/2023.

For example the table is like this (data from several years appear but I just want to compare the current year with 2019)

josefmc08_4-1680017983394.png

What I am looking for is to be able to obtain a result like this:

josefmc08_2-1680017686609.png

What I do NOT want is for it to come out like this:

josefmc08_3-1680017794217.png

Could you help me with a formula that would do it?

Thank you very much in advance.

2 REPLIES 2
Anonymous
Not applicable

Hi @Syndicate_Admin ,

 

I suggest you to try code as below to create a measure.

Measure = 
VAR _TODAY =
    TODAY ()
RETURN
    CALCULATE (
        SUM ( 'COMPLETE D_PEDIDO'[ENTRY ORDERS EUROS] ),
        FILTER (
            M_CALENDARIO,
            M_CALENDARIO[Year]
                IN { YEAR ( _TODAY ), 2019 }
                    && M_CALENDARIO[Month] <= MONTH ( _TODAY )
        )
    )

Result is as below.

vrzhoumsft_0-1680158854054.png

Best Regards,
Rico Zhou

 

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

Thank you very much for the help!.

With this solution I have the entry of orders month by month, but what I needed was the accumulated calculation, could you modify the measure to obtain the same calculation but accumulated?

Thank you

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.