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
Aymeric_bls
New Member

Running total with filters

Hello,

 

I'm currently trying to set-up a board where I could have an overview about the workloading of people per day.

I have a data table with the following inputs (the last column is a calculated column) :

TASK   PILOTE   STARTING_DATE   ENDING_DATE   WORKLOAD (in hour)   WORKLOAD_PER_DAY (Workload / (end-start))
1a19/04/202121/04/202166h / 3 = 2h per day
2a20/04/2021

22/04/2021

99h / 3 = 3h per day
3b19/04/202122/04/202188h / 4 = 2h per day
4c19/04/202120/04/202188h / 2 = 4h per day

 

I set up a calendar data base where I want to create a measure that will cumulate the daily workload of each tasks in order to have a visual chart and make sure the cumulated workload of each day is not more than x hours.

In this measure, I'd like to include a filter in order to vizualize this chart for each pilote.

In my mind, it looks like :

 

For each day of the Calendar table,

if STARTING_DATE <= Calendar[DATE] and ENDING_DATE > Calendar[DATE] and PILOTE = the one selected in the filters

then sum all the WORKLOAD_PER_DAY

 

It should return something like the following result :

 

Calendar data table for PILOTE = a :

DATEMeasure of Daily workload
19/04/2021  |  2 hours (task 1 only)
20/04/2021  |  5 hours (task 1 + task 2)
21/04/2021  |  5 hours (task 1 + task 2)
22/04/2021  |  3 hours (task 2 only)
23/04/2021  |  0 hours

 

Is there anybody who could guide me in this challenge ?

 

Thanks a lot for your help !

1 ACCEPTED SOLUTION
Anonymous
Not applicable

[Daily Workload] =
// This measure only works on the individual
// date level. If anything more than one day
// is visible in the current context - blank
// will be returned.
var vDateSelected = SELECTEDVALUE( Calendar[Date] )
var vSumOfWorkloadPerDay =
    CALCULATE(
        SUM( T[Workload_Per_Day] ),
        // Note that you should not slice
        // by any columns in your fact table.
        // Please use dimensions instead.
        // The only exception to this rule is
        // a degenerate dimension (but you
        // don't seem to have it). Also, this code
        // assumes that Starting_Date and
        // Ending_Date can't be BLANK.
        KEEPFILTERS( T[Starting_Date] <= vDateSelected ),
        KEEPFILTERS( vDateSelected < T[Ending_Date] )
    )
RETURN
    vSumOfWorkloadPerDay

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

[Daily Workload] =
// This measure only works on the individual
// date level. If anything more than one day
// is visible in the current context - blank
// will be returned.
var vDateSelected = SELECTEDVALUE( Calendar[Date] )
var vSumOfWorkloadPerDay =
    CALCULATE(
        SUM( T[Workload_Per_Day] ),
        // Note that you should not slice
        // by any columns in your fact table.
        // Please use dimensions instead.
        // The only exception to this rule is
        // a degenerate dimension (but you
        // don't seem to have it). Also, this code
        // assumes that Starting_Date and
        // Ending_Date can't be BLANK.
        KEEPFILTERS( T[Starting_Date] <= vDateSelected ),
        KEEPFILTERS( vDateSelected < T[Ending_Date] )
    )
RETURN
    vSumOfWorkloadPerDay

Hello Daxer,

Your solution works perfectly, thanks a lot ! 😊

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.

Top Solution Authors