Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi all!
I have created a matrix with a summary of information, it has two date fields and a calculation of days using the DATEDIFF function. The problem is that I need to count the days without duplicating the days.
As you can see in the table, for example row 2 and 3 overlap in the whole month of February of 1995, but I need to consider only 28 days of February, not 56 (obviously because February had 28 days in 1995). I have thought of creating a new table with the sequence of dates for each of the companies and then count distinct days, but I don't know if that will be the solution and maybe is overcomplicating the things.
I appreciate a lot your help.
Thanks,
Juan
Solved! Go to Solution.
I can't think of anything else other than using PQ to create rows of dates using the from and to date columns and then get the distinct count of those new dates so they are not counted multiple times in the total. Please see sample pbix.
Hi John, your idea is going in the right direction: the best solution is to create a table with all the unique dates between the start and end dates by company, and then count the different days. You can do this with DAX using GENERATE and CALENDAR:
DAX
Unique Days =
SUMMARIZE(
GENERATE(
Board
CALENDAR(Table[StartDate], Table[EndDate])
),
Table[Company], [Date]
)
You then simply count the different values of [Date] per company to avoid duplicates, ensuring that overlapping days are not added twice.
I'm trying to wrap my head around but just can't understand your explanation. I'm not seeing 56 anywhere and it appears that datediff is calculating correctly.
Hi! Sorry for not explaining me better.
Taking as the example rows 2 and 3, you will be able to see that:
The thing here is that the sample data relates to jobs a person had in the past. In the example, that person had 2 jobs for the same period (1 Feb to 28 Feb, 1995), but the days worked remain as 28. If we sum rows 2 and 3, we will be duplicating days for February, but that's incorrect because the person didn't work double, he worked 28 days in two (or more than two) different jobs during the same period.
So my problem is that I need to avoid duplicating the days, but with the current sum I'm not able to prevent the duplication.
I hope this illustrates better my problem.
Thanks a lot for replying to my message and hopefully we will reach to a solution!
Juan
I can't think of anything else other than using PQ to create rows of dates using the from and to date columns and then get the distinct count of those new dates so they are not counted multiple times in the total. Please see sample pbix.
Hey! The Power Query solution worked as desired! In the end, it was a matter of adding all the dates, thanks to you and Power Query, that was done automatically 😅.
My only worry about that approach is the refresh might take a very long time on a large table. For a few thousand rows, the latency if there is should be negligible.
That's true. But I guess it is anyway a good approach since for other customers, I might be facing the same. I will start using a single file per customer and if needed, create a summary file in Excel. Thank you!
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 57 | |
| 44 | |
| 42 | |
| 21 | |
| 17 |
| User | Count |
|---|---|
| 183 | |
| 114 | |
| 93 | |
| 62 | |
| 45 |