Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am working on my dashboard and I came across a problem:
I need to create a measure to calculate how many days are included in my filter (ex. Jan1 - March 31 = 89 days)
My filter is in the upper right hand corner to get these dates from.... just not sure how to go about this!
Solved! Go to Solution.
Hi, @Anonymous
Refer to the method provided by @amitchandak
Days:
Just use the method provided by @amitchandak
_Count days =
VAR _max =
MAXX ( ALLSELECTED ( 'Date' ), 'Date'[date] )
VAR _min =
MINX ( ALLSELECTED ( 'Date' ), 'Date'[date] )
RETURN
DATEDIFF ( _min, _max, DAY ) + 1
For counting weeks, it's not clear whether you want interval weeks based on the calendar or on the number of days in the interval.
Weeks: On days
_Count days(Week) =
VAR _max =
MAXX ( ALLSELECTED ( 'Date' ), 'Date'[date] )
VAR _min =
MINX ( ALLSELECTED ( 'Date' ), 'Date'[date] )
RETURN
ROUNDUP ( DIVIDE ( DATEDIFF ( _min, _max, DAY ) + 1, 7 ), 0 )
Weeks: On Calendar
_Count weeks =
VAR _max =
MAXX ( ALLSELECTED ( 'Date' ), 'Date'[date] )
VAR _min =
MINX ( ALLSELECTED ( 'Date' ), 'Date'[date] )
RETURN
DATEDIFF ( _min, _max, WEEK ) + 1
Is this the result you want? Hope this is useful to you
Please feel free to let me know If you have further questions
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous
Refer to the method provided by @amitchandak
Days:
Just use the method provided by @amitchandak
_Count days =
VAR _max =
MAXX ( ALLSELECTED ( 'Date' ), 'Date'[date] )
VAR _min =
MINX ( ALLSELECTED ( 'Date' ), 'Date'[date] )
RETURN
DATEDIFF ( _min, _max, DAY ) + 1
For counting weeks, it's not clear whether you want interval weeks based on the calendar or on the number of days in the interval.
Weeks: On days
_Count days(Week) =
VAR _max =
MAXX ( ALLSELECTED ( 'Date' ), 'Date'[date] )
VAR _min =
MINX ( ALLSELECTED ( 'Date' ), 'Date'[date] )
RETURN
ROUNDUP ( DIVIDE ( DATEDIFF ( _min, _max, DAY ) + 1, 7 ), 0 )
Weeks: On Calendar
_Count weeks =
VAR _max =
MAXX ( ALLSELECTED ( 'Date' ), 'Date'[date] )
VAR _min =
MINX ( ALLSELECTED ( 'Date' ), 'Date'[date] )
RETURN
DATEDIFF ( _min, _max, WEEK ) + 1
Is this the result you want? Hope this is useful to you
Please feel free to let me know If you have further questions
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , Try a measure like
New measure =
var _max = maxx(allselected('Date', 'Date'[date])
var _min= minx(allselected('Date', 'Date'[date])
return
datediff(_min,_max, day) // add +1 if needed ie:: datediff(_min,_max, day) +1
That works! How would I do it to count weeks? (weeks instead of days?)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
97 | |
96 | |
81 | |
74 | |
66 |
User | Count |
---|---|
126 | |
106 | |
105 | |
86 | |
72 |