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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

YTD last year DAX

I have YTD and last year YTD in different columns and how can I see YTD value for 2017 and 2018 when the year 2018 is selected in a year slicer?

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

It seems like your records are in same table, maybe you can use 'all' function to replace 'all selected' to break current filter effect to let formula calculate on whole table:

 

Utfall YTDLY =
CALCULATE (
    SUM ( 'Transaktion'[konto] ),
    FILTER (
        ALL( 'Transaktion' ),
        [Datum]
            >= DATE ( YEAR ( TODAY () ) - 1, 1, 1 )
            && [Datum]
                <= (
                    DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), 1 )
                        - 1
                )
    )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

6 REPLIES 6
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

 

You can use date and YTD columns to create table visual, then write a measure to look up last year YTD column and add it to current visual.

Share some data if you confused on coding formula.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

 
Anonymous
Not applicable

@v-shex-msft

 I want to get YTD values from January till the end of last month so I used the following formula to create a measure for YTD and YTD LY

Utfall YTD = CALCULATE(SUM('Transaktion'[konto]),FILTER('Transaktion',[Datum]>=DATE(YEAR(TODAY()),1,1) && [Datum] <=(DATE(YEAR(TODAY()),MONTH(TODAY()),1)-1)))

 

Utfall YTD  LY= CALCULATE(SUM('Transaktion'[konto]),FILTER('Transaktion',[Datum]>=DATE(YEAR(TODAY())-1,1,1) && [Datum] <=(DATE(YEAR(TODAY())-1,MONTH(TODAY()),1)-1)))

hI @Anonymous,

 

I'd like to suggest you use allselected function to filter use filtered table contents to calculate with your measure formula:

Utfall YTD =
CALCULATE (
    SUM ( 'Transaktion'[konto] ),
    FILTER (
        ALLSELECTED ( 'Transaktion' ),
        [Datum] >= DATE ( YEAR ( TODAY () ), 1, 1 )
            && [Datum]
                <= ( DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), 1 ) - 1 )
    )
)


Utfall
YTDLY =
CALCULATE (
    SUM ( 'Transaktion'[konto] ),
    FILTER (
        ALLSELECTED ( 'Transaktion' ),
        [Datum]
            >= DATE ( YEAR ( TODAY () ) - 1, 1, 1 )
            && [Datum]
                <= (
                    DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), 1 )
                        - 1
                )
    )
)

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

@v-shex-msftThank you, but it still shows me the same problem.

when the year 2018 is selected YTD LY doesn't appear.

below is my sample file 

Capture2.PNG

 

Capture 3.PNG

Hi @Anonymous,

 

It seems like your records are in same table, maybe you can use 'all' function to replace 'all selected' to break current filter effect to let formula calculate on whole table:

 

Utfall YTDLY =
CALCULATE (
    SUM ( 'Transaktion'[konto] ),
    FILTER (
        ALL( 'Transaktion' ),
        [Datum]
            >= DATE ( YEAR ( TODAY () ) - 1, 1, 1 )
            && [Datum]
                <= (
                    DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), 1 )
                        - 1
                )
    )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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