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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
arielfilipa
Advocate I
Advocate I

Year-To-Date Calculation

Hi,

 

I have a raw data with the information per Yearmonth divided between priorities and with a Created sum.

raw data.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Then in the Power BI Desktop, I've uploaded this information and created a variable to calculate the YTD.

 

YTD = 
VAR RowDate = 'YTD'[Yearmonth]
RETURN
    CALCULATE (
        SUM ( 'YTD'[Created] );
        FILTER (
            ALL('YTD');
            'YTD'[Yearmonth] <= RowDate
			 && YEAR ( 'YTD'[Yearmonth]) = YEAR ( RowDate )    
        )
    )

And it works however with a slicer for the priority the YTD doesn't changed.

Can you please help me ?

 

PBIX.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-haibl-msft
Microsoft Employee
Microsoft Employee

@arielfilipa

 

It seems that you created a calculate column for the YTD. To make it changed based on the selection, you need to create a calculated measure with following formula.

 

YTD_Measure = 
VAR RowDate =
    CALCULATE ( MAX ( 'YTD'[Yearmonth] ) )
RETURN
    CALCULATE (
        SUM ( 'YTD'[Created] ),
        FILTER (
            ALLSELECTED ( 'YTD' ),
            'YTD'[Yearmonth] <= RowDate
                && YEAR ( 'YTD'[Yearmonth] ) = YEAR ( RowDate )
        )
    )

Year-To-Date Calculation_1.jpg

 

Best Regards,
Herbert

View solution in original post

3 REPLIES 3
v-haibl-msft
Microsoft Employee
Microsoft Employee

@arielfilipa

 

It seems that you created a calculate column for the YTD. To make it changed based on the selection, you need to create a calculated measure with following formula.

 

YTD_Measure = 
VAR RowDate =
    CALCULATE ( MAX ( 'YTD'[Yearmonth] ) )
RETURN
    CALCULATE (
        SUM ( 'YTD'[Created] ),
        FILTER (
            ALLSELECTED ( 'YTD' ),
            'YTD'[Yearmonth] <= RowDate
                && YEAR ( 'YTD'[Yearmonth] ) = YEAR ( RowDate )
        )
    )

Year-To-Date Calculation_1.jpg

 

Best Regards,
Herbert

Hi Herbert (@v-haibl-msft),

 

Now I would like to show just a shorter number of yearmonths but if I remove yearmonths the YTD values change and the YTD for P12 2016 for example isn't the total of the year even if I have the data available in the raw data.

 

Is there a way to shorten the view but keeping the values ?

 

Thanks,

Filipa

Hi Herbert (@v-haibl-msft),

 

It works 🙂

 

Thanks!! 🙂

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors