Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Calculating projected spend between two dates

Hi,   I have a table of work orders. Each row has an unique ID, a start date, an end date, and a daily bill rate. With this, I need to calculate the projected spend into the future based on the dif...
  • DataInsights's avatar
    2 years ago

    Anonymous,

     

    Try this calculated table. It returns a row for each day within the start/end dates for each WorkOrderID. Instead of adding blank fact table rows for every day in your DimDate table (bloats your fact table), you could create a relationship between DimDate and ProjectedSpend. Then, in visuals use DimDate and specify "Show items with no data" if you want to see every row in DimDate.

     

    ProjectedSpend = 
    VAR vProjectedSpend =
        GENERATE (
            Workorder,
            VAR vStartDate = Workorder[Workorder Start Date]
            VAR vEndDate = Workorder[Workorder End Date]
            VAR vCalendar =
                CALENDAR ( vStartDate, vEndDate )
            RETURN
                vCalendar
        )
    VAR vResult =
        SELECTCOLUMNS (
            vProjectedSpend,
            "Date", [Date],
            "WorkOrderID", Workorder[WorkOrderID],
            "Projected Spend", Workorder[Daily Bill Rate]
        )
    RETURN
        vResult