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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
insandur
Helper II
Helper II

Calculate Selected Year & Month's YTD and Previous year ytd for the same month in filter selection

Hi All,

 

 I am struggling to calculate ytd for the selected year & month  and previous year YTD for the same selected month in filter.

 

For example, if i select FY 2023 YTD July in filter, it should provide me the year to date value starts from Jan 2023 upto July 2023. And it should also provide me the previous year to date value starts from Jan 2022 upto July 2022.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @insandur ,

Please try the following methods and check if they can solve your problem:

1.Create the simple table.

vjiewumsft_0-1710224504330.png

2.Select the slicer visual and drag the month into the visual.

vjiewumsft_1-1710224521797.png

3.Select the slicer visual and drag the year into the visual.

vjiewumsft_2-1710224531829.png

 

4.Create the measure to calculate YTD.

 

YTD = CALCULATE (
        SUM ('Table'[Values]),
        FILTER (
            ALL ('Table'),
            'Table'[Year] = SELECTEDVALUE('Table'[Year])
                && 'Table'[Month] <= SELECTEDVALUE('Table'[Month])
        )
    )

 

 

5.Create the measure to calculate previous YTD .

 

pre_YTD = CALCULATE (
        SUM ('Table'[Values]),
        FILTER (
            ALL ('Table'),
            'Table'[Year] = (SELECTEDVALUE('Table'[Year]) - 1)
                && 'Table'[Month] <= SELECTEDVALUE('Table'[Month])
        )
    )

 

6.Drag the measure into the card visual. The result is shown below.

vjiewumsft_4-1710224671823.png

 

Best Regards,

Wisdom Wu

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

3 REPLIES 3
Anonymous
Not applicable

Hi @insandur ,

Please try the following methods and check if they can solve your problem:

1.Create the simple table.

vjiewumsft_0-1710224504330.png

2.Select the slicer visual and drag the month into the visual.

vjiewumsft_1-1710224521797.png

3.Select the slicer visual and drag the year into the visual.

vjiewumsft_2-1710224531829.png

 

4.Create the measure to calculate YTD.

 

YTD = CALCULATE (
        SUM ('Table'[Values]),
        FILTER (
            ALL ('Table'),
            'Table'[Year] = SELECTEDVALUE('Table'[Year])
                && 'Table'[Month] <= SELECTEDVALUE('Table'[Month])
        )
    )

 

 

5.Create the measure to calculate previous YTD .

 

pre_YTD = CALCULATE (
        SUM ('Table'[Values]),
        FILTER (
            ALL ('Table'),
            'Table'[Year] = (SELECTEDVALUE('Table'[Year]) - 1)
                && 'Table'[Month] <= SELECTEDVALUE('Table'[Month])
        )
    )

 

6.Drag the measure into the card visual. The result is shown below.

vjiewumsft_4-1710224671823.png

 

Best Regards,

Wisdom Wu

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

 

 

 

 

 

 

 

 

 

 

 

 

StrategicSavvy
Resolver II
Resolver II

hi @insandur 

 

you can also try with explicit measures:

1. Total YTD

Total YTD = 
CALCULATE(
    SUM ( 'Fact'[Value] ),
    DATESYTD('Calendar'[Date])
)

 

2. Total PYTD

Total PYTD = 
CALCULATE(
    [Total YTD],
    DATEADD(
        'Calendar'[Date],-1,YEAR)
        )
    )

 

Hope it helps.

lbendlin
Super User
Super User

Please try the "Running totals" Quick Measure.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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