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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

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

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
Solution Supplier
Solution Supplier

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

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
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors
Top Kudoed Authors