Forum Discussion
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:
I'm waiting (refreshing the internet page) to your solution 😄
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.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,
3 Replies
- Kaviraj11
Solution Sage
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.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,
- Yazid
Helper I
Thanks a lot !
- Ashish_Mathur
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.