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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
MORGANC846
New Member

DAX Help Please. Calculate the total days for multiple people on multiple tasks in a time period.

Hi All,

 

I am hoping someone can help me. I am trying to create a measure to display on a card, that will calculate the total days spent on multiple tasks by multiple people within 'this' month.

 

So far I have the measure below, which is close, but totals the enitre duration of tasks that fit the criteria, i.e the start and end date fall within the parameters, however I only want it to include the days on task in 'this' month. Month being determined by a slicer / filter.

 

VAR WFDS This Month =
VAR MaxDate = MAX('CALENDAR'[Date])
VAR MinDate = MIN('CALENDAR'[Date])
 
RETURN
CALCULATE(
[duration](
FILTER(
'TableA' 'TableA'[START DATE] <= MaxDate && 'TabelA'[END DATE] >= MinDate ) ) ,
CROSSFILTER(
'CALENDAR'[Date] 'TabelA'[START DATE] None ) )
 
This is a small sample of the data I am using.
 
For each task how many workforce days have been spent in 'this' month?
Anne for example has spent 109 workforce days on Task A, but how many were spent in October 22? She was committed for the whole of October so 31.  Additionally, Kelly for example has spent 35 days on Task C, however only 20 of those days were spent in October. The current Dax includes the full duration of both Anne and Kelly's tasks.
 
SerEvent TypeEvent NameStart DateEnd DateDurationName
1TaskA29/08/202216/12/2022109Anne
2TaskA29/08/202216/12/2022109Brian
3TaskA29/08/202216/12/2022109Colin
4TaskA29/08/202216/12/2022109Dave
5TaskA29/08/202216/12/2022109Emma
6TaskB10/10/202229/10/202219Farah
7TaskB10/10/202229/10/202219George
8TaskB10/10/202229/10/202219Hayley
9TaskB10/10/202229/10/202219India
10TaskB10/10/202229/10/202219Julie
11TaskC15/09/202220/10/202235Kelly
12TaskC15/09/202220/10/202235Liam
13TaskC15/09/202220/10/202235Mike
14TaskC15/09/202220/10/202235Natalie
15TaskC15/09/202220/10/202235Oscar
16TaskD25/10/202225/11/202231Pete
17TaskD25/10/202225/11/202231Rachel
18TaskD25/10/202225/11/202231Stef
 
1 ACCEPTED SOLUTION
mangaus1111
Solution Sage
Solution Sage

Hi @MORGANC846 ,

 

1) you have to create this snapshot table:

 

Snapshot_Table =
GENERATE(
         'Facts',
         DATESBETWEEN(
                      'Date'[Date],
                      'Facts'[Start Date], 'Facts'[End Date]
                      )
)
 
2) create this measure:
CountDays = COUNTROWS('Snapshot_Table')
 
3) create a relationship between the Date Table and the Snapshot_Table
 
Finally you can slice the column [Year-Month] from the Date Table in this way
 
mangaus1111_0-1666550786401.pngmangaus1111_1-1666550850268.png

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

3 REPLIES 3
mangaus1111
Solution Sage
Solution Sage

Hi @MORGANC846 ,

 

1) you have to create this snapshot table:

 

Snapshot_Table =
GENERATE(
         'Facts',
         DATESBETWEEN(
                      'Date'[Date],
                      'Facts'[Start Date], 'Facts'[End Date]
                      )
)
 
2) create this measure:
CountDays = COUNTROWS('Snapshot_Table')
 
3) create a relationship between the Date Table and the Snapshot_Table
 
Finally you can slice the column [Year-Month] from the Date Table in this way
 
mangaus1111_0-1666550786401.pngmangaus1111_1-1666550850268.png

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

mangaus1111
Solution Sage
Solution Sage

Hi @MORGANC846 ,

 

see my pbi file. Let me know if the link does not work.

 

https://1drv.ms/u/s!Aj45jbu0mDVJiyIF6BMMp6YfTJLq?e=82WjjQ

 

 

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

Hi,

 

Thank you for your reply, unfortuneately the link is restricted by my work security.

Helpful resources

Announcements
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.