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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
yiying
Helper I
Helper I

How to calculate days worked

So here is my data

Full NameDateDays Worked
ANTHONY 3/1/2018 0:001
ANTHONY 3/3/2018 0:001
ANTHONY 3/6/2018 0:001
ANTHONY 3/7/2018 0:001
ANTHONY 3/7/2018 0:001
ANTHONY 3/8/2018 0:001
GRANT 3/1/2018 0:001
GRANT 3/2/2018 0:001
GRANT 3/2/2018 0:001
GRANT 3/3/2018 0:001
GRANT 3/5/2018 0:001
GRANT 3/6/2018 0:001
GRANT 3/8/2018 0:001
GRANT 3/8/2018 0:001
GRANT 3/9/2018 0:001
GRANT 3/9/2018 0:00

1

 

 The duplicate date means that person have 2 activity that day.

I write a DAX for my measure like this :

Days Worked =
SUMX(VALUES('Complete WO'[Tech ID]),DISTINCTCOUNT('Complete WO'[DateKey]))

The duplicate date means that person have 2 activity that day.

It works fine when I filter down to one person. However in this table, it always give me 16 instead of 12.

How should I write my DAX correctly? 

 

2 ACCEPTED SOLUTIONS
v-jiascu-msft
Employee
Employee

Hi @yiying,

 

Try out this measure please.

Measure =
COUNTX (
    SUMMARIZE ( 'Complete WO', 'Complete WO'[Full Name], 'Complete WO'[Datekey] ),
    [Datekey]
)

How_to_calculate_days_worked

 

Best Regards,

Dale

Community Support Team _ Dale
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

Ashish_Mathur
Super User
Super User

Hi,

 

This measure gives 12 as the answer

 

=COUNTROWS(SUMMARIZE(Data,Data[Full Name],Data[Date]))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

6 REPLIES 6
v-jiascu-msft
Employee
Employee

Hi @yiying,

 

Could you please mark the proper answer as solution?

 

Best Regards!
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

 

This measure gives 12 as the answer

 

=COUNTROWS(SUMMARIZE(Data,Data[Full Name],Data[Date]))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-jiascu-msft
Employee
Employee

Hi @yiying,

 

Try out this measure please.

Measure =
COUNTX (
    SUMMARIZE ( 'Complete WO', 'Complete WO'[Full Name], 'Complete WO'[Datekey] ),
    [Datekey]
)

How_to_calculate_days_worked

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
chethan
Resolver III
Resolver III

@yiying Bro

 

If the Person is visiting two Times, there will be the time stamp too. So separate the date only & use the Distance count. 

 

I will work,

 

 

Regards,

Chetan K

jthomson
Solution Sage
Solution Sage

Is there more data in your table that you need to retain outside of these fields you list, or could you not look at the full name and date fields and remove duplicates?

I need to keep those data. That duplicate means that person have 2 activity that day. Sorry about the confusion. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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