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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register 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

)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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

)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.