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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Joynul
Frequent Visitor

Calculating remaining Capacity, if Employee has no work then return the

Hi folks,

 

Please can you take a look at the below and see if you can help me resolve this issue, If you need anymore details please let me know.

 

Problem Statement: I'm encountering an issue with a DAX measure in my Power BI model where it's not returning the expected result of 5 (Max Capacity) when an employee has no work assigned to them that week.

 

Background:

  • I have a Power BI model that involves two tables: F_Capacity and DIM_Team_Details.
  • The measure in question, called "Remaining Capacity," calculates the remaining capacity for each employee and week based on certain conditions, including "Consumed Days."
  • The intention is to return 5 when "Consumed Days" is blank or zero, indicating that there's no work for that week.

What I've Tried:

  • I've attempted various DAX formulas and measures to explicitly handle blank or zero values in "Consumed Days" but haven't achieved the desired result.
  • I've ensured that the "Consumed Days" column is of the correct data type (numeric) in both tables.
  • I've validated the data and confirmed that there are indeed cases where "Consumed Days" is blank or zero.

Example of the Measure: Here is the DAX measure that I've been using:

Remaining Capacity = 
VAR MaxCapacityTable = SUMMARIZE(DIM_Team_Details, DIM_Team_Details[EmployeeID], DIM_Team_Details[Max Capacity], DIM_Team_Details[Start Date], DIM_Team_Details[End Date])
RETURN
SUMX(
ADDCOLUMNS(
SUMMARIZE(
F_Capacity,
F_Capacity[EmployeeID],
DIM_Calendar[Week_Commencing]
),
"Max Capacity",
MAXX(FILTER(MaxCapacityTable, F_Capacity[EmployeeID] = DIM_Team_Details[EmployeeID]), DIM_Team_Details[Max Capacity]),
"Start Date",
MINX(FILTER(MaxCapacityTable, F_Capacity[EmployeeID] = DIM_Team_Details[EmployeeID]), DIM_Team_Details[Start Date]),
"End Date",
MAXX(FILTER(MaxCapacityTable, F_Capacity[EmployeeID] = DIM_Team_Details[EmployeeID]), DIM_Team_Details[End Date])
),
IF(
[Start Date] > [Week_Commencing] || [End Date] < [Week_Commencing],
0,
IF(
ISBLANK([Consumed Days]) || [Consumed Days] = 0,
5,
IF(
[Consumed Days] <= [Max Capacity],
[Max Capacity] - [Consumed Days],
0
)
)
)
)

Below are the tables I am using

 

Joynul_0-1696972703524.pngJoynul_1-1696972736697.png

 

Joynul_2-1696972776208.png

 

Finally this is the script that I am using for the measure Consumed Days

 

Consumed Days = 

SUMX(

    SUMMARIZE(

        F_Capacity,

        F_Capacity[EmployeeID],

        DIM_Calendar[Week_Commencing],

        "Consumed Days", SUM(F_Capacity[Days_Worked])

    ),

    [Consumed Days]

)
 
Relationships below
 
Joynul_0-1697012533322.png

 

 

Thank you in advance for taking a look at this.

1 ACCEPTED SOLUTION
Joynul
Frequent Visitor

FYI - this script manages to resolve the question

 

Remain Cap Test = 

VAR CurrentDate = MAX(DIM_Calendar[Week_Commencing])

VAR CurrentDateID = LOOKUPVALUE(DIM_Calendar[DateID],DIM_Calendar[Week_Commencing],CALCULATE(MAX(DIM_Calendar[Week_Commencing]), FILTER(DIM_Calendar, DIM_Calendar[Week_Commencing] <= CurrentDate)))

VAR WeekCount = CALCULATE(COUNTA(DIM_Calendar[DateID]))

VAR MaxCapacity =

    CALCULATE(SUM(Dim_Team_Details[Max Capacity]),

        FILTER(

            Dim_Team_Details,

           

            CurrentDate >= Dim_Team_Details[Start Date] &&

            CurrentDate <= Dim_Team_Details[End Date]

        )

    ) * WeekCount

VAR FilteredCapacity =

    CALCULATE(SUM(F_Capacity[Days_Worked]),

        FILTER(

            F_Capacity,

            F_Capacity[DateID] <= CurrentDateID

           

        )

       

    )

   

RETURN

   MaxCapacity - FilteredCapacity

View solution in original post

3 REPLIES 3
Joynul
Frequent Visitor

FYI - this script manages to resolve the question

 

Remain Cap Test = 

VAR CurrentDate = MAX(DIM_Calendar[Week_Commencing])

VAR CurrentDateID = LOOKUPVALUE(DIM_Calendar[DateID],DIM_Calendar[Week_Commencing],CALCULATE(MAX(DIM_Calendar[Week_Commencing]), FILTER(DIM_Calendar, DIM_Calendar[Week_Commencing] <= CurrentDate)))

VAR WeekCount = CALCULATE(COUNTA(DIM_Calendar[DateID]))

VAR MaxCapacity =

    CALCULATE(SUM(Dim_Team_Details[Max Capacity]),

        FILTER(

            Dim_Team_Details,

           

            CurrentDate >= Dim_Team_Details[Start Date] &&

            CurrentDate <= Dim_Team_Details[End Date]

        )

    ) * WeekCount

VAR FilteredCapacity =

    CALCULATE(SUM(F_Capacity[Days_Worked]),

        FILTER(

            F_Capacity,

            F_Capacity[DateID] <= CurrentDateID

           

        )

       

    )

   

RETURN

   MaxCapacity - FilteredCapacity
vanessafvg
Super User
Super User

are you able to supply the data in text format?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




please see data below.

 

Table Name - F_Capacity
Days_WorkedUtilisationIDEmployeeIDUserStoryID

EpicID

DateIDForecasted CapexUtilized Percentage
1162491242139020.00%
0.5167191242119510.00%
310210912422117060.00%
0.5168191242219510.00%
0.5187291242219510.00%
0.511129124219510.00%
31261091242117060.00%
0.519719124219510.00%
0.511229124319510.00%
31271091243117060.00%

 

 

Table Name - Dim_Team_Details
NameTitleStart DateEnd DateShort TitleEmployeeIDMax Capacity
John Smith2 - Design Authority01-Jan-2001-Dec-22Authority15
Random Guy2 - Design Authority01-Jun-2201-May-40Authority25
Blue Cat4 - Analyst01-Aug-2301-May-40Analyst35
Jane Doe4 - Analyst01-May-2001-May-40Analyst45
John Doe4 - Analyst01-May-2001-Sep-23Analyst55

 

 

Table Name - DIM_Calendar

DateIDWeek_CommencingMonthFiscal YearQuarter
127-Mar-2301-Mar-23FY22/23Q4
203-Apr-2301-Apr-23FY23/24Q1
310-Apr-2301-Apr-23FY23/24Q1
417-Apr-2301-Apr-23FY23/24Q1
524-Apr-2301-Apr-23FY23/24Q1
601-May-2301-Apr-23FY23/24Q1
708-May-2301-May-23FY23/24Q1
815-May-2301-May-23FY23/24Q1
922-May-2301-May-23FY23/24Q1
1029-May-2301-May-23FY23/24Q1
1105-Jun-2301-Jun-23FY23/24Q1
1212-Jun-2301-Jun-23FY23/24Q1
1319-Jun-2301-Jun-23FY23/24Q1
1426-Jun-2301-Jun-23FY23/24Q1
1503-Jul-2301-Jul-23FY23/24Q2
1610-Jul-2301-Jul-23FY23/24Q2
1717-Jul-2301-Jul-23FY23/24Q2
1824-Jul-2301-Jul-23FY23/24Q2
1931-Jul-2301-Jul-23FY23/24Q2
2007-Aug-2301-Aug-23FY23/24Q2
2114-Aug-2301-Aug-23FY23/24Q2
2221-Aug-2301-Aug-23FY23/24Q2
2328-Aug-2301-Aug-23FY23/24Q2
2404-Sep-2301-Sep-23FY23/24Q2
2511-Sep-2301-Sep-23FY23/24Q2
2618-Sep-2301-Sep-23FY23/24Q2
2725-Sep-2301-Sep-23FY23/24Q2
2802-Oct-2301-Oct-23FY23/24

Q3

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors