Parameters - without changing the view

I find myself, more often every week, in a need to be able for users to enter some data that doesn’t act as WHERE clause in the query.

Assuming the parameter is one of those that doesn’t really fit in any of the views, can it be achieved only using front-end?

Let’s say I want people to choose a date and then I want to be able to create a custom filter that filters the data from -30 of that date until that date. Perhaps there are easier ways to achieve that?

I’ve read this Great Use Cases for Parameter Fields and as great as it is I’m trying to find a simpler way without going into the view because the parameter is only needed for my particular look

That’s really the key — Parameters could definitely be leveraged do to what you just described, but if you only need it for one Look, it could clutter things up. I can’t really think of a better way to do it.

If you wanted to use a custom filter, you could create a pass-through dimension that’s hidden that referenced the value of a parameter in it’s SQL. Then you could refer to that dimension in your custom filter. You could even set the parameter to hidden: yes too once you’ve added it to the relevant explore so it doesn’t cause clutter or confusion.

Tell me if I understand you correctly:

  1. Create parameter in a view called A
  2. Created hidden field named B and for value use liquid markup to insert value of the A
  3. Use that hidden dimension in filter
    3b. Use liquid directly in SQL

Does this look okay?

Dawid, here’s how I accomplished this to allow users to sum up sales over a date range, and also to shift it forward/backwards by a specified number of days, using exactly the method you’re describing:

  1. Make a date-type parameter for users to select a date range selected_range
  2. Make an unquoted-type parameter for users to select a number of days to shift date_offset
  3. Make an off-screen date filter which takes the date_start and date_end from selected_range and adds date_offset to both - sales_date_filter
  4. Apply sales_date_filter through a Liquid condition to your filtered measure

I can post my code in about a week to show you specifically how this looked, and apologize if I mucked my description here a bit.

I endorse that approach! Sounds perfectly reasonable.

@bens could you still post it? I’m coming back to exploring this but I still can’t grasp how I can just create filter in a look rather than a view. The view has a data that’s used for many different reports but I have one report that shows data for yesterday, always yesterday.

I’m trying to change it so that it works as yesterday OR a selected date if selected

Dawid - I’ll see what I can do over the next week or so - it’s a particularly busy time of year right now :slight_smile: