Forum Discussion
Caculate value between dates and value without enddate
- 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.
Hi AltusTellus ,
SImply add the paremeter OR (||^) with only start date:
WorkingHours_v2 =
VAR MinDate =
MIN ( 'tb_SchedulesCalendar'[Date] )
VAR MaxDate =
MAX ( 'tb_SchedulesCalendar'[Date] )
RETURN
CALCULATE (
SUM ( 'tb_Schedules'[AverageHours] );
FILTER (
tb_Schedules;
tb_Schedules[StartDate] <= MaxDate
&& tb_Schedules[EndDate] >= MinDate
|| tb_Schedules[StartDate] <= MaxDate
)
)
Check PBIX attach
- AltusTellus6 years ago
Helper III
Hi MFelix ,
Thnx for your reply, but I have another problem after using the OR function like you described. The result is that a following schedule (e.g. the same ID has a follower at the first of January but with 36 as number for [AverageHours), it counts up the original [AvarageHours] with the follower schedule. Like this:ID 201910 201911 201912 202001 1002 40 40 40 76 This means that in the matrix the result unfortunately is not like this:
ID 201910 201911 201912 202001 1002 40 40 40 36 Do you have a solution for this problem? Many thanks again.
- MFelix6 years ago
Super User
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.
- AltusTellus6 years ago
Helper III
MFelix THANKS!