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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors