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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Date Diff in custom visual/grouping

Hi All 

 

i have a custom column which calculates the length of service for leavers (Month date diff between start and end date) 


then have another column which then divides the above by 12 to get years of service, ie 1.33 -  i did have these rounded to do full years of service in a visual 

 

The requirement has now changed to look something like the below - i just wanted thoughts on how the most efficient way of dealing with, is it a case of a long IF statement to return a number sequence linked to a new custom table?

 

TIA 

 

David 

 Leavers
10 years +2
9-10 years1
8-9 years2
7-8 years3
6-7 years2
5-6 years 3
4-5 years2
3-4 years 5
2-3 Years5
1-2 years5
6-12 Months4
0-6 months 5
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , You can create a bucket like, a new column 

 

New column=

var _diff = datediff([start date], [end date], month)/12c

Switch(true() ,

_diff <= .5 , "   0 - 6 Month",

_diff <= 1, "   6 - 12 Month",

_diff <=2 , "  1 -2 Years",

// Keep on additing other

)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , You can create a bucket like, a new column 

 

New column=

var _diff = datediff([start date], [end date], month)/12c

Switch(true() ,

_diff <= .5 , "   0 - 6 Month",

_diff <= 1, "   6 - 12 Month",

_diff <=2 , "  1 -2 Years",

// Keep on additing other

)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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