Forum Discussion

spuff55's avatar
spuff55
Frequent Visitor
5 years ago
Solved

Creating a date spread table for activities and resource

Hi   I've been trying to figure this out for too long and need some help.   I have a database containing activity data with multiple resources assigned per activity, Each row contains Activity...
  • v-cazheng-msft's avatar
    v-cazheng-msft
    5 years ago

    Hi, spuff55 

    Sorry for late reply. You can create a Calculated table and a Calculated column to get the result you want.

     

    1 Calculated table

    Table =
    
    VAR cal =
    
        SELECTCOLUMNS (
    
            FILTER (
    
                CALENDAR ( MIN ( RESOURCE[Start] ), MAX ( RESOURCE[Finish] ) ),
    
                DAY ( [Date] ) = 1
    
            ),
    
            "Period", [Date]
    
        )
    
    VAR cross_t =
    
        FILTER (
    
            CROSSJOIN ( RESOURCE, cal ),
    
            [Period] >= RESOURCE[Start]
    
                && [Period] <= RESOURCE[Finish]
    
        )
    
    VAR sel_t =
    
        SELECTCOLUMNS (
    
            cross_t,
    
            "Period Start Date", [Period],
    
            "ActivityID", [Activity ID],
    
            "Resource", [Recource],
    
            "Budget_overall", [Budget]
    
        )
    
    RETURN
    
        sel_t
    
    
    
    
    
    2 Calculated column
    
    Budget =
    
    VAR num =
    
        CALCULATE (
    
            COUNT ( 'Table'[Budget_overall] ),
    
            ALLEXCEPT ( 'Table', 'Table'[ActivityID], 'Table'[Resource] )
    
        )
    
    RETURN
    
        'Table'[Budget_overall] / num

     

     

    The result looks like this:

     

     

    Here is the pbix.

     

    Best Regards,

    Caiyun Zheng

     

  • spuff55's avatar
    spuff55
    5 years ago

    That works great, thank you!