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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Nicpet0
Regular Visitor

Calculating Year To Date and Full Year

Hi Community

I am asking for your help with a DAX measure i cant seem to figure out how to put together. Here is what i require.

I want to create a bar chart that could look similar to the snippet i provided. (it shows year to date values from current fiscal year 2024-25) and four years back. 

However, i want to create a DAX measure that shows year to date, for my current fiscal year, i have a measure for that, where it takes into consideration my month selected in a slicer. Anything that is not current fiscal year should return the full year and disregard the month.

I hope someone can help me provide what the code would look like to achieve this. 

Nicpet0_0-1726647016300.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Nicpet0 ,

I create a table as you mentioned.

vyilongmsft_0-1726711062748.png

Then I create a measure and here is the DAX code.

Measure = 
VAR _CurrentFY_YTD =
    CALCULATE ( SUM ( 'Table'[Amount] ), DATESYTD ( 'Table'[Date], "6/30" ) )
VAR _FullYear_PreviousYears =
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        ALLEXCEPT ( 'Table', 'Table'[FiscalYear] )
    )
RETURN
    IF (
        MAX ( 'Table'[FiscalYear] ) = "2024-25",
        _CurrentFY_YTD,
        _FullYear_PreviousYears
    )

vyilongmsft_1-1726711185341.png

So when I select the slicer, it will get what you want in the bar chart.

vyilongmsft_2-1726711264186.png

vyilongmsft_3-1726711283997.png

 

 

 

Best Regards

Yilong Zhou

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Nicpet0 ,

I create a table as you mentioned.

vyilongmsft_0-1726711062748.png

Then I create a measure and here is the DAX code.

Measure = 
VAR _CurrentFY_YTD =
    CALCULATE ( SUM ( 'Table'[Amount] ), DATESYTD ( 'Table'[Date], "6/30" ) )
VAR _FullYear_PreviousYears =
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        ALLEXCEPT ( 'Table', 'Table'[FiscalYear] )
    )
RETURN
    IF (
        MAX ( 'Table'[FiscalYear] ) = "2024-25",
        _CurrentFY_YTD,
        _FullYear_PreviousYears
    )

vyilongmsft_1-1726711185341.png

So when I select the slicer, it will get what you want in the bar chart.

vyilongmsft_2-1726711264186.png

vyilongmsft_3-1726711283997.png

 

 

 

Best Regards

Yilong Zhou

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

Selva-Salimi
Super User
Super User

Hi @Nicpet0 

 

you can write a measure as follows:

 

measure YTD := var this_year = max( dimdate[year]) -- or you also can write year(today()), depend to your data

return

calculate(sum(quantity) , filter (all(your_table) , your_table[year] = this_year))

 

If this post helps, then I would appreciate a thumbs up  and mark it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.