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!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! 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.