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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Add YTD and LYTD calculated column to Table Date

Greeting Guys , 

 

i want to add a 2 calculated column into my Date Table called "ContainInYTD" and "ContainInLYTD" 

 

This column equals True if the row belong to the YTD and False if not . (Based on the current date)

 

Exemple : 

since we are in march ,the rows from january to march equals to true the others rows equal to false . is it possible ? 

 

Thanks all in advance 😊. ( i can explain more if needed ) 

1 REPLY 1
DataInsights
Super User
Super User

@Anonymous,

 

Try these calculated columns:

 

ContainInYTD = 
VAR vToday =
    TODAY()
VAR vYear =
    YEAR ( vToday )
VAR vResult =
    IF ( DIM_DATE[DATE] <= vToday && DIM_DATE[YEAR] = vYear, 1, 0 )
RETURN
    vResult

ContainInLYTD = 
VAR vToday =
    TODAY ()
VAR vYear =
    YEAR ( vToday )
VAR vMonth =
    MONTH ( vToday )
VAR vDay =
    DAY ( vToday )
VAR vResult =
    IF (
        DIM_DATE[DATE]
            <= DATE ( vYear - 1, vMonth, vDay )
            && DIM_DATE[YEAR] = vYear - 1,
        1,
        0
    )
RETURN
    vResult

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.