Forum Discussion

lookingfo123's avatar
lookingfo123
New Member
3 years ago
Solved

Categorize a year column

I have a column that tracks earliest retirement dates (its a date column). I need a new column that will break these out in to ranges. For example if the earliest retirement date is 02/02/2025, this should be categorized in the 2-3 year (from today's date) category. Can anyone help me with the dax for this? 

  •  

    Hello lookingfo123 ,

     

    You can do something as follow :

     

     

     

    Category = SWITCH(YOUR_TABLE[DATE].[Year] - YEAR(TODAY()), 0 , "This year", 1 || 2, "2 to 3 years", 3 || 4 , "4 to 5 years", "Older")

     

     

    OR 

     

    Category = CONCATENATE(YOUR_TABLE[Date].[Year] - YEAR(TODAY()), " year")

    Have a nice day

     

1 Reply

  •  

    Hello lookingfo123 ,

     

    You can do something as follow :

     

     

     

    Category = SWITCH(YOUR_TABLE[DATE].[Year] - YEAR(TODAY()), 0 , "This year", 1 || 2, "2 to 3 years", 3 || 4 , "4 to 5 years", "Older")

     

     

    OR 

     

    Category = CONCATENATE(YOUR_TABLE[Date].[Year] - YEAR(TODAY()), " year")

    Have a nice day