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
ArtNo1000
Regular Visitor

Showing average planned hours by day

Hi

 

I have a consolidated table like below and would like to build a simple forecast where I calculate average hours per day going forward. Any tips on how I can achive this?

 

Currently the "OrderDate" column is related to the date table, but its between StartDate and EndDate I need to do the forecast. 

 

Table     
OrderIDOrderDateStartDateEndDatePLanned timeAlready logged time
12021-03-012021-03-222021-03-265015

 

 

Result:   
Calender[Date]Planned timeLogged timeRemaining time
2021-03-2210100
2021-03-231055
2021-03-2410010
2021-03-2510010
2021-03-2610010
1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi

You can try the following steps.

 

1 Create a Calculated table

Result =

VAR cal =

    SELECTCOLUMNS (

        CALENDAR ( MIN ( 'Table'[StartDate] ), MAX ( 'Table'[EndDate] ) ),

        "date", [Date]

    )

VAR cross_t =

    FILTER (

        CROSSJOIN ( 'Table', cal ),

        [date] >= 'Table'[StartDate]

            && [date] <= 'Table'[EndDate]

    )

VAR sel_t =

    SELECTCOLUMNS (

        cross_t,

        "OrderID", [OrderID],

        "Calendar [Date]", [date],

        "Planned time", [PLanned time],

        "already", [Already logged time]

    )

RETURN

    sel_t

 

2 Create two Measures

Logged time =

VAR res =

    CALCULATE (

        SUM ( Result[Average planned time] ),

        FILTER (

            ALLEXCEPT ( Result, Result[OrderID] ),

            Result[Calendar_Date] <= MAX ( Result[Calendar_Date] )

        )

    )

VAR mid_res =

    res - MAX ( Result[already] )

RETURN

    IF (

        mid_res >= MAX ( Result[Average planned time] ),

        0,

        IF (

            mid_res > 0

                && mid_res < MAX ( Result[already] ),

            mid_res,

            MAX ( Result[Average planned time] )

        )

    )

 

Remaining time =

VAR res =

    CALCULATE (

        SUM ( Result[Average planned time] ),

        FILTER (

            ALLEXCEPT ( Result, Result[OrderID] ),

            Result[Calendar_Date] <= MAX ( Result[Calendar_Date] )

        )

    )

VAR mid_res =

    MAX ( Result[already] ) - res

RETURN

    IF ( mid_res < 0, 0, mid_res )

 

Create a table visual and the result looks like this:

v-cazheng-msft_0-1616994890752.png

 

For more details, you can refer the attached pbix.

 

Best Regards

Caiyun Zheng

 

Is that the answer you're looking for? 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

1 REPLY 1
v-cazheng-msft
Community Support
Community Support

Hi

You can try the following steps.

 

1 Create a Calculated table

Result =

VAR cal =

    SELECTCOLUMNS (

        CALENDAR ( MIN ( 'Table'[StartDate] ), MAX ( 'Table'[EndDate] ) ),

        "date", [Date]

    )

VAR cross_t =

    FILTER (

        CROSSJOIN ( 'Table', cal ),

        [date] >= 'Table'[StartDate]

            && [date] <= 'Table'[EndDate]

    )

VAR sel_t =

    SELECTCOLUMNS (

        cross_t,

        "OrderID", [OrderID],

        "Calendar [Date]", [date],

        "Planned time", [PLanned time],

        "already", [Already logged time]

    )

RETURN

    sel_t

 

2 Create two Measures

Logged time =

VAR res =

    CALCULATE (

        SUM ( Result[Average planned time] ),

        FILTER (

            ALLEXCEPT ( Result, Result[OrderID] ),

            Result[Calendar_Date] <= MAX ( Result[Calendar_Date] )

        )

    )

VAR mid_res =

    res - MAX ( Result[already] )

RETURN

    IF (

        mid_res >= MAX ( Result[Average planned time] ),

        0,

        IF (

            mid_res > 0

                && mid_res < MAX ( Result[already] ),

            mid_res,

            MAX ( Result[Average planned time] )

        )

    )

 

Remaining time =

VAR res =

    CALCULATE (

        SUM ( Result[Average planned time] ),

        FILTER (

            ALLEXCEPT ( Result, Result[OrderID] ),

            Result[Calendar_Date] <= MAX ( Result[Calendar_Date] )

        )

    )

VAR mid_res =

    MAX ( Result[already] ) - res

RETURN

    IF ( mid_res < 0, 0, mid_res )

 

Create a table visual and the result looks like this:

v-cazheng-msft_0-1616994890752.png

 

For more details, you can refer the attached pbix.

 

Best Regards

Caiyun Zheng

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

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.