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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
vinidegrandi
Regular Visitor

Calculate with items in the same column

I am trying to calculate the hours worked per month for every employee. This is based on a Sharepoint list. Their usernames go into the title column, then the ActivityType column details what they did (Check In, Lunch Out, Lunch In, Check Out) and ActivityDateTime details the exact time they did such activity. Is there any way I can calculate the time between Check In and Check Out within the same column? If I create a column for each activity type I'll have to redo the entire Canvas App that I have for time tracking that uses this list as data source.

 

vinidegrandi_0-1671122299234.png

 

2 ACCEPTED SOLUTIONS
v-jayw-msft
Community Support
Community Support

Hi @vinidegrandi ,

 

Try below formula:

time_diff = 
var Check_In = calculate(max([activitydatetime]), filter(yourtable,[activitytype]=earlier([activitytype])-1))

Return
datediff(Check_In,[activitydatetime],HOUR)

 

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

@vinidegrandi 
Your ActiveType is a "Text" type. Please change its type to "Number" then you could use the DAX above.

 

Best Regards.

View solution in original post

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @vinidegrandi ,

 

Try below formula:

time_diff = 
var Check_In = calculate(max([activitydatetime]), filter(yourtable,[activitytype]=earlier([activitytype])-1))

Return
datediff(Check_In,[activitydatetime],HOUR)

 

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

Its displaying an error saying that the DAX comparison does not offer support for a comparison between a number and a text. Its suggesting using VALUE or FORMAT. 

@vinidegrandi 
Your ActiveType is a "Text" type. Please change its type to "Number" then you could use the DAX above.

 

Best Regards.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.