Forum Discussion
Filter visual date axis range based on selected date
- 7 years ago
Hi Anonymous,
From my understand, you want to show the date range in axis from the beginning of the year to the date month you select in date slicer?
So when I select "September" in my slicer, the bar chart should only show data from January till December. When I select "July", it should only show January till July.
However, I have a little confused that why the bar chart should show data January till December when you select "September" in slicer? Do you have a written mistake or that is what you want?
If you want the axis to display the data for the beginning of the year until the month selected in the slicer.
You could create another date table with Calendar fucntion and do not create relationship between the two tables.
Then create the measure with the formula below.
Measure = VAR a = MONTH ( MAX ( 'Calendar'[Date] ) ) RETURN CALCULATE ( SUM ( 'Table'[Amount] ), FILTER ( 'Table', 'Table'[Date] >= STARTOFYEAR ( 'Calendar'[Date] ) && 'Table'[Date] <= MAX ( 'Calendar'[Date] ) && MONTH ( 'Table'[Date] ) <= a ) )Here is the output.
For more details, you could refer to my attachment.
Best Regards,
Cherry
Hi Anonymous,
From my understand, you want to show the date range in axis from the beginning of the year to the date month you select in date slicer?
So when I select "September" in my slicer, the bar chart should only show data from January till December. When I select "July", it should only show January till July.
However, I have a little confused that why the bar chart should show data January till December when you select "September" in slicer? Do you have a written mistake or that is what you want?
If you want the axis to display the data for the beginning of the year until the month selected in the slicer.
You could create another date table with Calendar fucntion and do not create relationship between the two tables.
Then create the measure with the formula below.
Measure =
VAR a =
MONTH ( MAX ( 'Calendar'[Date] ) )
RETURN
CALCULATE (
SUM ( 'Table'[Amount] ),
FILTER (
'Table',
'Table'[Date] >= STARTOFYEAR ( 'Calendar'[Date] )
&& 'Table'[Date] <= MAX ( 'Calendar'[Date] )
&& MONTH ( 'Table'[Date] ) <= a
)
)
Here is the output.
For more details, you could refer to my attachment.
Best Regards,
Cherry
Can you also help me?
I need to have a moving months on x-axis based on the slicer selection. x-axis needs to show 6 months depending on slicer:
Ex: if selected month on slicer is Dec'19; x-axis to show Jul'19 to Dec'19. On the other hand, if selected month on slicer is Sep'19 then x-axis to show Apr'19 to Sep'19.
Thanks in advance!