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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Yazid
Helper I
Helper I

Truncate a column based on a year

Dear,

I'd like to truncate my date colum as function of the year. Namely, i'd like to return a column but with the only date in 2024.

Here below the expected results:

Yazid_0-1718131213532.png

 

I'm waiting (refreshing the internet page) to your solution 😄 

1 ACCEPTED SOLUTION
Kaviraj11
Super User
Super User

Hi,

 

You will need to create a calculated column

 

New StartDate =
VAR _Year=YEAR(TODAY())
RETURN SWITCH(TRUE(), YEAR('Fact'[StartDate])=_Year,'Fact'[StartDate],BLANK())
 
You can replace the variable _Year with any condition or static value.
 
Kaviraj11_0-1718134946724.png

 

If you would like to display only date of that year, you can filter out the date when is blank in Filter pane as well.

 

Regards,

 
 



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

Proud to be a Super User!





View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table with a relationship (Many to One and Single) from the Date column of your Fact Table to the Date column of the Calendar Table.  In the Calendar Table, create a calculated column of Year.  To a slicer, drag Year from the Calnedar Table and select 2024.  To your Table visual, drag Date from the Calendar Table. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Kaviraj11
Super User
Super User

Hi,

 

You will need to create a calculated column

 

New StartDate =
VAR _Year=YEAR(TODAY())
RETURN SWITCH(TRUE(), YEAR('Fact'[StartDate])=_Year,'Fact'[StartDate],BLANK())
 
You can replace the variable _Year with any condition or static value.
 
Kaviraj11_0-1718134946724.png

 

If you would like to display only date of that year, you can filter out the date when is blank in Filter pane as well.

 

Regards,

 
 



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

Proud to be a Super User!





Thanks a lot !

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.