Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello!
I am trying to get a distinct count of ID's noted within a specific date range. My table has columns with ID's, start and end dates.
I can get the total rows that fall within the date range on any given day from the following:
Solved! Go to Solution.
Hi,
According to your description, I can roughly understand your requirement, you want to get a distinct count of ID's noted within a specific date range, right? I think you can try this method to get the expected result:
This is the test data I created based on your description:
You can create a calendar table to be placed into the slicer:
Calendar = CALENDAR(DATE(2022,1,1),DATE(2022,1,5))
Then you can create a measure like this:
Distinct count =
var _start=MINX(ALLSELECTED('Calendar'),'Calendar'[Date])
var _end=MAXX(ALLSELECTED('Calendar'),'Calendar'[Date])
return
CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER(ALL('Table'),[Start Date]>=_start&&[End Date]<=_end))
And you can create a slicer and a card chart to get what you want, like this:
You can download my test pbix file below
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Thank you very much!
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
According to your description, I can roughly understand your requirement, you want to get a distinct count of ID's noted within a specific date range, right? I think you can try this method to get the expected result:
This is the test data I created based on your description:
You can create a calendar table to be placed into the slicer:
Calendar = CALENDAR(DATE(2022,1,1),DATE(2022,1,5))
Then you can create a measure like this:
Distinct count =
var _start=MINX(ALLSELECTED('Calendar'),'Calendar'[Date])
var _end=MAXX(ALLSELECTED('Calendar'),'Calendar'[Date])
return
CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER(ALL('Table'),[Start Date]>=_start&&[End Date]<=_end))
And you can create a slicer and a card chart to get what you want, like this:
You can download my test pbix file below
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Thank you very much!
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I think you might be making life hard for yourself with the nested SWITCH/If when you could be using CALCULATE.
Are you able to share a demo pbix? Fairly sure we should be able to help.
Ben
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
13 | |
11 | |
10 | |
7 | |
7 |
User | Count |
---|---|
13 | |
12 | |
12 | |
9 | |
8 |