Forum Discussion
Syndicate_Admin
2 years agoAdministrator
Counting Between Dates
Good day, I'm new to power bi and I'm having problems with a formula that at first glance seems simple. I have already seen other similar posts in this forum, but I have not found a response. I have...
Anonymous
2 years agoNot applicable
Hi, Syndicate_Admin
Based on your information, I create a sample table:
Then create a new measure and try the following DAX expression:
Historical Assets =
VAR MinYear = YEAR(MIN('Table'[Start Date]))
VAR MaxYear = YEAR(MAX('Table'[End Date]))
RETURN
SUMX(
GENERATESERIES(MinYear, MaxYear, 1),
VAR CurrentYear = [Value]
RETURN
CALCULATE(
COUNTROWS('Table'),
'Table'[Start Date] <= DATE(CurrentYear, 12, 31) &&
'Table'[End Date] >= DATE(CurrentYear, 1, 1)
)
)
Here is my preview:
How to Get Your Question Answered Quickly
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Syndicate_Admin
2 years agoAdministrator
Thank you very much for your answer, but the data you provide are not correct. For example, in 2016 there is only one service.
The correct answers would be:
2016: 1
2017: 5
2018: 15
2019: 24
2020: 22
2021: 22
2022: 27
2023: 33
2024: 31