The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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.