Tableau: Sliding filter for date, but with a fixed range - tableau-api

I'm trying to create a sliding filter for date in Tableau, but I want the range to be fixed to one day.
For example, the whole filter scale will be from Jan 1, 2020 to December 31, 2020.
I want the viewer to be able to slide along the scale to select a specific date (e.g. June 6, 2020 - June 6, 2020), but not be able to change the size of the range to something longer than one day.
Hope that makes sense. Thanks in advance!

Sticking to filters, do you have already turned your filter data into a discrete filter (blue pill)?
If so, then you should be able to edit your filter and presenting it like a single value / slider.
If you're open to use parameter, you can right-click your date column and select Create-Parameter.
Doing so you should be getting a parameter already filled with all the dates in your column which you can then modify (if you want to get rid of some dates).
Once you show your parameter, it will appear in your worksheet/dashboard and you can edit especially in terms of how it looks like.
In your scenario, you probably want to set it as a slider:
Since the parameter alone won't filter your data, you also need to create a Calculated field with a condition.

Related

How to display date from a specific month in Excel Pivot Chart

I want my chart showing period from FEB-2020 to DEC-2021. However, if i filter away January, it will remove January for 2020 & 2021. This is because, "Years" & "Date" They are independent filters. How to only filter away JAN-2020 only?
I have figured out.
If create using pivot chart, we can either show month with no data or show month only data. However, show month with no data, u will show full year-month for 2020 which is unwanted.
For pivot chart, u have only 1 way to control month to display is to create dummy data for that month. Then, run a macro to delete "(blank)" legend.
Hit me up, if anyone interested to know more.☺

How can I set a non-continuous date filter?

I need to be able to filter my data to comparable weeks/months across various years. And I need to be able to update those choices on the fly. Is there a way in tableau to set a non-continuous date filter?
because the base data is saved on the tableau server, I'm unable to join additional tables to it, so my initial idea of making a table of year / start date / end date and joining that to my data with a simple t/f filter isn't panning out.
I've considered making series of parameters, but it seems like it might get a bit overwhelming to make so many
Other things I've considered is writing an extended rule like
IF [year] = 2015 THEN [date]BETWEEN(date A, date B)
or the tableau equivalent to BETWEEN
ELSEIF [year] = 2016 THEN [date]BETWEEN(date C, Date D)
ELSE IF //and so forth
Does anyone else have experience with this? Any strategies you might recommend on the parameters vs. a long formula?
Any ideas are greatly appreciated!
Standard tableau filters on dates allow filtering by both continuous date ranges or filtering by parts of dates.
For example, if you wanted to compare January sales cross multiple years, you can drag your date field to the filters shelf and then right-click the date field in the shelf and choose "Discrete" rather than "Continuous" or choose "Month" in the upper set of options about which date component you want (the upper set selects date components, the lower set selects date ranges with in filters and axes).
So, if you put a date field on the filters shelf and select "month" as a discrete you will get a filter that allows you to filter for every January in the dataset.

PowerBI: How to display/filter row tables between 2 years dynamically

I was wondering if there's a way where I can filter out my table results based on two years. My table A has date column and many miscellaneous columns. So currently I would like the table A to display January 2018 (or 1/1/2018) and December 2019 (or 12/31/2019 --basically ongoing) information. However, once January 1st, 2020 appears, I would like my table A to display row results between January 2019 and December 2020. Is there a way I can do so? Maybe in DAX or clicking some filter option? Could someone show me? I'm still fairly new to PowerBI.
Thanks
The easiest way to meet this requirement is usually using the Relative Date Slicer or Filter functionality:
https://learn.microsoft.com/en-us/power-bi/visuals/desktop-slicer-filter-date-range
Not sure if any of those options will meet your scenario. Maybe Last 12 Months (Calendar)? Your requirements description didnt make much sense to me - you probably need to explain "ongoing" and "appears".
If the Relative Date functions dont meet your needs, then you'll need to construct a column (in Power Query or DAX) that returns a static value you can use in a Slicer or Filter.

SSRS Preset or Custom Date Selection on Report

I currently have a report with the ability to select a start and end date. I was curious if you could make have both preset and the option for a custom selection
Selection:
Current Week, or
Previous Week, or
Custom Date Range.
Thanks,
Take a look at cascading parameters.
The link above seems to focus more on getting your cascading parameter values from a query, but you probably don't want that for a date - as far as I am aware, setting Available Values for a date parameter limits you to a dropdown list of dates, instead of the calendar which is generally easier to use. It is still a good background on how cascading parameters work though.
To do this with expressions for the default start/end date, you would basically want the first parameter to be a choice between "Current Week", "Previous Week", and "Custom Date Range". You would display those labels to the user, but the values can be whatever you want - for my test I just used 1, 2, and 3.
Then, you would set up 2 more parameters, one for the start date and one for the end date. Make sure the data type is Date. You will want to set up default values for these based on the value of the first parameter. I would do this with an expression such as the expression below for the start date. You also may need to modify this a bit depending on how you define the week - is the "Current Week" just the previous 7 days, or is it the latest Monday through today, or something else, etc.
=Switch(
Parameters!FirstParam.Value = 1, DateAdd("d", -7, Today()),
Parameters!FirstParam.Value = 2, DateAdd("d", -14, Today())
)
In this case, you don't even need to account for the 3rd option, because if the user wants a custom date range then you do not want the start and end date to fill in with any default values. You would need a similar expression for the default end date as well.
Since you want the user to be able to enter a custom range as well if they were to select the third option, you do not want to fill in the Available Values for the start/end date parameters, as the user would then not be able to select any date (at least as far as I am aware - if there is a workaround to that, I would love to see it, as that would be something I would like to use myself).
A possible downside to this approach is that if the user begins by selecting Current Week and then changes their mind to Previous Week, the start/end dates will not change to the Previous Week. You can read more about why this happens here, but essentially: since the values that are already filled in after selecting Current Week are still valid (they are dates, which is the only criteria for those parameters since no available values are set up), they will not refresh after changing the selection. The fix for this is to define the Available Values, but as mentioned above, this will then stop the user from entering a custom date range.

Change filter order of values based on parameter

​Hi all,
I am trying to change the order of the values in the filter based on a parameter I've chosen. For example if I choose "Calendar" in the parameter, I'd want my filter values to start from January, February, March... until December. If I choose "Financial" in my parameter, I'd want it to start from July, August, September... Til June as the last month.
How can I implement this?
Thanks
I would create additional calculated fields that represent the numerical order of my months. For example, "calendar" would give January a value of 1, Feb 2, and so on. In a similar manner, "financial" would give July 1, Sept 2, etc.
From there, you can make a parameter control that dictates the sort that you should use. This is a great tutorial on doing that.
Create Parameter control for sort in Tableau
The generated sort fields that are created to dictate the sort order should not have to be shown on your final viz.