Forum Discussion

AltusTellus's avatar
AltusTellus
Icon for Helper III rankHelper III
6 years ago
Solved

Caculate value between dates and value without enddate

Hi all,   I'm struggeling with a DAX formula for calculating the value of hours between dates in combination with the value of hours from a startdate.   I've two tables: 1. Schedules with column...
  • MFelix's avatar
    MFelix
    6 years ago

    Hi AltusTellus ,

     

    I just used you measure that you made, you are summing values, depending on the values you have and number of lines you can change the SUM for MIN, MAX or AVERAGE.

     

    Using the MIN it's giving correct result:

    WorkingHours_v2 = 
    VAR MinDate = MIN( 'tb_SchedulesCalendar'[Date] )
    VAR MaxDate = MAX( 'tb_SchedulesCalendar'[Date] )
    RETURN CALCULATE(MIN('tb_Schedules'[AverageHours]),
                   FILTER(
                   tb_Schedules,
                   tb_Schedules[StartDate] <= MaxDate
                           && tb_Schedules[EndDate] >= MinDate || tb_Schedules[StartDate] <= MaxDate
                           
                   )
    )

     

    See PBIX file attach.