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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Babycakes
Helper II
Helper II

Function to extract column data

Hi There,

 

We  have a data set that I am trying to create a formula for;

 

Trying to define this one shift but each shift is different buy basic principle applies.

Shift starts Monday week 1 at 3 pm and 3 pm to 10 pm is paid afternoon rate

 

Same shift is split so two lines in data set.

 

Second component is hence on Week 1 Tuesday 6 am to 9am

How do i create a formula that identifies this eg changes to 3 pm to 10 pm when it is two seperate lines.

I have attached the sheet

Current

Shift StartSleepover StartSleepover FinishAllocated Shift Break (mins)Shift FinishWorked Hours in DayShift SplitsTotal shift hoursWeekDay
3:00 PM10:00 PM6:00 AM09:00 AM7.00 420, 480, 180101Monday
3:00 PM10:00 PM6:00 AM09:00 AM3.00 420, 480, 180101Tuesday
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Babycakes 

You can refer to the following solution.

1.Create a Index column

Index = var a=ADDCOLUMNS('Table',"DayNum",SWITCH([Day],"Monday",1,"Tuesday",2,"Wednesday",3,"Thursday",4,"Friday",5,"Saturday",6,"Sunday",7))
return RANKX(FILTER(a,[Shift Start]=EARLIER('Table'[Shift Start])),[Day],,ASC)

2.Then create the following columns

Sub_Shift Start = IF([Index]=1,[Shift Start],[Sleepover Finish])
Sub_Shift Finish = IF([Index]=1,[Sleepover Start],[Shift Finish])

Output

vxinruzhumsft_1-1698978278092.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Babycakes 

You can refer to the following solution.

1.Create a Index column

Index = var a=ADDCOLUMNS('Table',"DayNum",SWITCH([Day],"Monday",1,"Tuesday",2,"Wednesday",3,"Thursday",4,"Friday",5,"Saturday",6,"Sunday",7))
return RANKX(FILTER(a,[Shift Start]=EARLIER('Table'[Shift Start])),[Day],,ASC)

2.Then create the following columns

Sub_Shift Start = IF([Index]=1,[Shift Start],[Sleepover Finish])
Sub_Shift Finish = IF([Index]=1,[Sleepover Start],[Shift Finish])

Output

vxinruzhumsft_1-1698978278092.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Babycakes
Helper II
Helper II

Result

Shift StartSleepover StartSleepover FinishAllocated Shift Break (mins)Shift FinishWorked Hours in DayShift SplitsTotal shift hoursWeekDay
3:00 PM10:00 PM6:00 AM010:00 PM7.00 420, 480, 180101Monday
6:00 AM10:00 PM6:00 AM09:00 AM3.00 420, 480, 180101Tuesday

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.