Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin 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.
Hi everyone,
I have this code working to count the number of days there is between 2 dates.
VAR StartDate = MIN(_datemin_swapped, _datemax_swapped)
VAR EndDate = MAX(_datemin_swapped, _datemax_swapped)
VAR WeekendCount = COUNTROWS(FilteredDates)
Solved! Go to Solution.
Hi @pintoan
Two issues with your second expression:
The error message relates to point 1, since BLANK() is (possibly) passed as an argument of COUNTROWS.
Here is one way of fixing this (with some additional tweaks to the code):
VAR WeekendCount =
IF (
NOT ( StartDate = 0 || EndDate = 0 ), -- just test for 0 since BLANK() = 0
VAR FilteredDates =
FILTER (
CALENDAR ( StartDate, EndDate ),
WEEKDAY ( [Date] ) IN { 1, 7 } // 1 = Sunday, 7 = Saturday
)
RETURN
COUNTROWS ( FilteredDates )
)
Does this work for you?
Regards
Hi @pintoan
Two issues with your second expression:
The error message relates to point 1, since BLANK() is (possibly) passed as an argument of COUNTROWS.
Here is one way of fixing this (with some additional tweaks to the code):
VAR WeekendCount =
IF (
NOT ( StartDate = 0 || EndDate = 0 ), -- just test for 0 since BLANK() = 0
VAR FilteredDates =
FILTER (
CALENDAR ( StartDate, EndDate ),
WEEKDAY ( [Date] ) IN { 1, 7 } // 1 = Sunday, 7 = Saturday
)
RETURN
COUNTROWS ( FilteredDates )
)
Does this work for you?
Regards
thank you, perfect! marked as solution.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
61 | |
61 | |
55 | |
38 | |
27 |
User | Count |
---|---|
85 | |
60 | |
45 | |
41 | |
39 |