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
Hello,
I know this is an old post but I am struggling with a similar situation and hoping that you would have a solution. I have a calender table connected to a fact table with a date key. I have multiple visuals on my report page all of which use the calender table slicer date selection. There is one visual that needs to show last 3 months of data based the slicer selection. I have written a datediff measure which works fine on this visual if I disconnect the calender table from the fact table. However, I need the relationship between the two tables for my other visuals.
From the answer above in this post, it seems the USERELATIONSHIP function can help but I have no clue on how to implement it. I would really appreciate any guidance on it.
Please note that I cannot use measures like Previoumonth value etc to get around this problem since I this visual is a stacked bar chart that cannot handle multiple measures.
Thanks a lot,
Leena
SQLBI recently posted a nice tutorial on something similar which might prove useful:
https://www.sqlbi.com/articles/show-previous-6-months-of-data-from-single-slicer-selection/
(this works with any number of periods btw)
- Anonymous5 years agoNot applicable
Hi Anonymous , Greg_Deckler ,
I checked out SQL BI's article above and tried to implement that as well but it still did not work for me. Copying the link to the sample file for SQL BI's solution below. I have written to them too but would really appreciate if you could look into it as well.Sample File