Forum Discussion
Average total calculated by weekly date
- 3 years ago
Hi, KatBous
You can try the following methods.
Measure:Count open = VAR _N1 = CALCULATE ( COUNT ( 'Table'[Position Title] ), FILTER ( ALL ( 'Table' ), [Date position opened] <= SELECTEDVALUE ( 'Report date'[Date] ) && [Date position closed] >= SELECTEDVALUE ( 'Report date'[Date] ) && [Date position closed] <> BLANK () ) ) VAR _N2 = CALCULATE ( COUNT ( 'Table'[Position Title] ), FILTER ( ALL ( 'Table' ), [Date position closed] = BLANK () && [Date position opened] <= SELECTEDVALUE ( 'Report date'[Date] ) ) ) RETURN _N1 + _N2Count closed = CALCULATE ( COUNT ( 'Table'[Position Title] ), FILTER ( ALL ( 'Table' ), [Date position closed] <= SELECTEDVALUE ( 'Report date'[Date] ) && [Date position closed] <> BLANK () ) )Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you so much v-zhangti for the immediate and detailed reply!!!
One info that I forgot to include in my example table (new one below) is that some rows have blank "Date position closed" and "Time to recruit", as some positions are still open when I draft the report. How should I change the measures?
And also, using the measures, the table in PowerBi stops one week before the last week. It stops in 10 November while the last report date is 17 November.
| Position Title | Date position opened | Date position closed | Time to recruit |
| a | 18/10/2022 | 19/10/2022 | 2,00 |
| b | 18/10/2022 | 01/11/2022 | 15,00 |
| c | 20/10/2022 | ||
| d | 25/10/2022 | ||
| e | 25/10/2022 | ||
| f | 25/10/2022 | ||
| g | 25/10/2022 | ||
| h | 04/11/2022 | 14/11/2022 | 11,00 |
| i | 08/11/2022 |
Hi, KatBous
You can try the following methods.
Measure:
Count open =
VAR _N1 =
CALCULATE (
COUNT ( 'Table'[Position Title] ),
FILTER (
ALL ( 'Table' ),
[Date position opened] <= SELECTEDVALUE ( 'Report date'[Date] )
&& [Date position closed] >= SELECTEDVALUE ( 'Report date'[Date] )
&& [Date position closed] <> BLANK ()
)
)
VAR _N2 =
CALCULATE (
COUNT ( 'Table'[Position Title] ),
FILTER (
ALL ( 'Table' ),
[Date position closed] = BLANK ()
&& [Date position opened] <= SELECTEDVALUE ( 'Report date'[Date] )
)
)
RETURN
_N1 + _N2Count closed =
CALCULATE (
COUNT ( 'Table'[Position Title] ),
FILTER (
ALL ( 'Table' ),
[Date position closed] <= SELECTEDVALUE ( 'Report date'[Date] )
&& [Date position closed] <> BLANK ()
)
)
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.