Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
EmployeeID Start Date End Date
1 01/01/2021 31/12/2021
2 01/01/2022 31/03/2023
3 01/08/2023
4 01/01/2023
5 01/03/2023 31/08/2023
For the above scenario I want plot the Total Record Count on a Line Graph that shows me the ongoing Active Records taking into account the Date on the X-Axis and taking into account the Start and End Date of the Employee.
Any help or pointers appreciated!
Solved! Go to Solution.
Hi @derekmac
You need to have a disconnected date table. Your count measure would be:
Count =
SUMX (
VALUES ( 'Date'[Date] ),
COUNTROWS (
FILTER (
'Table',
'Table'[Start Date] <= 'Date'[Date]
&& COALESCE ( 'Table'[End Date], TODAY () ) >= 'Date'[Date]
)
)
)
@derekmac
Create a date table and keep it disconnected from the main table (no relationships). It should contain all the dates from minimum start date to the maximum end date. Example
Date = CALENDAR ( MIN ( 'Table'[Start Date] ), MAX ( 'Table'[End Date] ) )
Place 'Date'[Date] in a table visual along with the count measure
Count =
SUMX (
VALUES ( 'Date'[Date] ),
COUNTROWS (
FILTER (
'Table',
'Table'[Start Date] <= 'Date'[Date]
&& COALESCE ( 'Table'[End Date], TODAY () ) >= 'Date'[Date]
)
)
)
Please try
Count =
SUMX (
VALUES ( 'Date'[Date] ),
SUMX (
FILTER (
'Table',
'Table'[Start Date] <= 'Date'[Date]
&& COALESCE ( 'Table'[End Date], TODAY () ) >= 'Date'[Date]
),
'Table'[Target]
)
)
Hi
Total Prospects =
SUMX (
VALUES ( 'Dates'[End of Week] ),
COUNTROWS (
FILTER (
'Prospects',
'Prospects'[Date Added] <= 'Dates'[End of Week]
&& COALESCE ( Prospects[Date Closed], TODAY () ) >= 'Dates'[End of Week]
)
)
)
How would I amend the above to calculate only for the last 7 days?
I don't understand that
@derekmac
Create a date table and keep it disconnected from the main table (no relationships). It should contain all the dates from minimum start date to the maximum end date. Example
Date = CALENDAR ( MIN ( 'Table'[Start Date] ), MAX ( 'Table'[End Date] ) )
Place 'Date'[Date] in a table visual along with the count measure
Count =
SUMX (
VALUES ( 'Date'[Date] ),
COUNTROWS (
FILTER (
'Table',
'Table'[Start Date] <= 'Date'[Date]
&& COALESCE ( 'Table'[End Date], TODAY () ) >= 'Date'[Date]
)
)
)
Target
1
2
3
4
5
If I had a 4th Column called Target, how would I change the DAX to sum this column using the disconnected table instead of Counting Rows?
I want to add a target line to my Line Graph too
Thank you so much for you help so far, I have not come across this technique before, it is quite advanced for me!
Please try
Count =
SUMX (
VALUES ( 'Date'[Date] ),
SUMX (
FILTER (
'Table',
'Table'[Start Date] <= 'Date'[Date]
&& COALESCE ( 'Table'[End Date], TODAY () ) >= 'Date'[Date]
),
'Table'[Target]
)
)
Thank you so much
Hi @derekmac
You need to have a disconnected date table. Your count measure would be:
Count =
SUMX (
VALUES ( 'Date'[Date] ),
COUNTROWS (
FILTER (
'Table',
'Table'[Start Date] <= 'Date'[Date]
&& COALESCE ( 'Table'[End Date], TODAY () ) >= 'Date'[Date]
)
)
)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
11 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
12 | |
11 | |
11 | |
10 |