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
gatesmetbus
Frequent Visitor

YTD not working when year and month slicer used

My YTD measure matches my MTD measure. 

Abated Emergency WO MTD =
VAR SelectedMonth = SELECTEDVALUE('Day'[Month])
VAR SelectedYear = SELECTEDVALUE('Day'[Year])
RETURN
IF(
    NOT(ISBLANK(SelectedMonth)) && NOT(ISBLANK(SelectedYear)),
    TOTALMTD([Abated Emergency Work Orders], 'Day'[Date]),
    BLANK()
)
this gives me back the correct MTD each time. However I had silmair YTD measure it doesn't compute right it just matches the MTD amount. Ive tried to remove the filters within the dax, I've tried other Dax but always matches the MTD or just 0. 
 
I'm trying to recreate the matrix towards the left WITH the slicers.  Untitled.png
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @gatesmetbus 

 

 

Maybe you can choose to write the dax without Time intelligence functions:

Abated Emergency WO MTD =
VAR _currentdate =
    DAY ( MAX ( 'Day'[Date] ) )
VAR SelectedMonth =
    SELECTEDVALUE ( 'Day'[Month] )
VAR SelectedYear =
    SELECTEDVALUE ( 'Day'[Year] )
RETURN
    IF (
        NOT ( ISBLANK ( SelectedMonth ) ) && NOT ( ISBLANK ( SelectedYear ) ),
        CALCULATE (
            [Abated Emergency Work Orders],
            FILTER (
                ALL ( 'Day' ),
                'Day'[Date] <= _currentdate
                    && 'Day'[Date] >= DATE ( SelectedYear, 1, 1 )
            )
        ),
        BLANK ()
    )

 

Best Regards

Zhengdong Xu
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

4 REPLIES 4
elitesmitpatel
Super User
Super User

Hey @gatesmetbus 
Try this query for year calculation

 

Abated Emergency WO YTD =
VAR SelectedYear = SELECTEDVALUE('Day'[Year])
RETURN
IF(
NOT(ISBLANK(SelectedYear)),
TOTALYTD(
[Abated Emergency Work Orders],
'Day'[Date],
ALL('Day')
),
BLANK()
)

hey @elitesmitpatel ive tried that before and just not and no luck. Let me know what else I can share to help aid this

Anonymous
Not applicable

Hi @gatesmetbus 

 

 

Maybe you can choose to write the dax without Time intelligence functions:

Abated Emergency WO MTD =
VAR _currentdate =
    DAY ( MAX ( 'Day'[Date] ) )
VAR SelectedMonth =
    SELECTEDVALUE ( 'Day'[Month] )
VAR SelectedYear =
    SELECTEDVALUE ( 'Day'[Year] )
RETURN
    IF (
        NOT ( ISBLANK ( SelectedMonth ) ) && NOT ( ISBLANK ( SelectedYear ) ),
        CALCULATE (
            [Abated Emergency Work Orders],
            FILTER (
                ALL ( 'Day' ),
                'Day'[Date] <= _currentdate
                    && 'Day'[Date] >= DATE ( SelectedYear, 1, 1 )
            )
        ),
        BLANK ()
    )

 

Best Regards

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

hey thanks for answering i found a solution.

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.