Forum Discussion

EventHorizon99's avatar
EventHorizon99
New Member
3 years ago
Solved

adding data value with start and end dates for all dates

I am a newbie so please be gentle :   assume the following sample data table Team Start Date End Date Value A  1/01/2019  1/01/2022  6 A  1/01/2021  1/01/2023  4 E  1/01/2019...
  • EventHorizon99's avatar
    3 years ago

    Updated:

    I have used this thread to solve my problem. https://community.powerbi.com/t5/DAX-Commands-and-Tips/DAX-Calculate-the-sum-of-values-for-a-year-with-start-date-and/m-p/2352850

     

    [Edit] However I had to modify slightly as my rate was per year. Rather than divide by 365.25 I opted to use the 1st day of month for Crossjoin and therefore divide by 12.  Since my minimum duration is a month; this works out fine.

     

    this is my DAX followed by sum (not shown here)

     

    Workload Per Month =
    VAR PerMonthWorkload =
        ADDCOLUMNS (
            'Sample Data',
            "WorkloadPerMonth", DIVIDE ( 'Sample Data'[Value], 12)
        )
    VAR DailyTable =
        CROSSJOIN (FILTER('Calendar', DAY([Date])=1), PerMonthWorkload )
    VAR Result =
        FILTER (
            DailyTable,
            [Date] >= [Start Date]
                && [Date] < [End Date]
        )
    RETURN
        Result
     

     

     

  • EventHorizon99's avatar
    3 years ago

    responded too soon; still not resolved. workload per day does not align value which is per year value. I need to divide by number of days in a year for this to work.