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 dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
User | Count |
---|---|
77 | |
74 | |
42 | |
32 | |
28 |
User | Count |
---|---|
100 | |
93 | |
51 | |
50 | |
48 |