Forum Discussion
Dynamic X axis range based on the current Month
- Anonymous1 year ago
Hi Steamedbunz ,
Try applying the following measure to a visual filter:
MEASURE = VAR __today = TODAY () VAR __cur_date = SELECTEDVALUE ( 'Table'[Date] ) VAR __wk_monthstart = CALCULATE ( MAX ( 'Table'[WK MonthStart] ), 'Table'[Date] = __today ) VAR __wk_monthend = CALCULATE ( MAX ( 'Table'[WK MonthEnd] ), 'Table'[Date] = __today ) VAR __filter = IF ( __cur_date >= __wk_monthstart && __cur_date <= __wk_monthend, 1 ) RETURN __filterBest Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi Steamedbunz - Create two measures to calculate the WK MonthStart and WK MonthEnd for the current month, as the min and max range for the X-axis.
Min_X_Axis_Date =
CALCULATE(
MIN('Calendar'[WK MonthStart]),
FILTER(
'Calendar',
'Calendar'[Date] >= TODAY() && 'Calendar'[Date] <= EOMONTH(TODAY(), 0)
)
)
another measure for max date
Max_X_Axis_Date =
CALCULATE(
MAX('Calendar'[WK MonthEnd]),
FILTER(
'Calendar',
'Calendar'[Date] >= TODAY() && 'Calendar'[Date] <= EOMONTH(TODAY(), 0)
)
)
Use the Min_X_Axis_Date and Max_X_Axis_Date measures to filter your visual.
Apply these filters in the Filters pane to limit the X-axis range. For example, you can create a slicer or set up the visual-level filter to show only the dates between these two calculated values.
hope this helps you
Hi rajendraongole1 ,
Thanks for your reply. I've created those measures sucessfully and has verified the dates were indeed correct.
However, how can I apply those to filter a visual? When put in those filters, I've tried few different options, it still asked me to manually select a date?
Regards,