I'm trying to create a global filter in my dashboard that shows a UNION of two different fields, and then filters based on OR condition of the two fields. So example, fields in datasource are:
State / City;
Texas / Dallas;
Ohio / Cleveland;
New York / Ohio;
UNION of the two fields (State / City) would mean filter drop down shows all unique values:
[Texas, Dallas, Ohio, Cleveland, New York]
Filter behavior would be if you select 'Texas' you only return ['Texas / Dallas'], but if you selected 'Ohio' you would get ['Ohio / Cleveland', 'New York / Ohio']. (I know there is no city in New York named Ohio, bare with me). I can union my DS to get my list:
q = load "states";
q = group q by 'states;
q = foreach q generate 'states' as 'locationFilter';
s = load "cities";
s = group s by 'cities';
s= foreach s generate 'cities' as 'locationFilter';
t = union q, s;
order t by 'locationFilter' asc
But then how do I use that locationFilter field to populate my dropdown? Do I make the above query a SAQL type filter? I'm brand new to Einstein Analytics, and have watched a million youtube videos and read the developer reference for SAQL/JSON. My understanding is you can't have a global filter operate on more than one field, but you can do things manually in SAQL and potentially accomplish it there. Any guidance is much, much appreciated!
Hey @Micah McClelland, not sure if you still need help with this request. In case you still do, here's what you can do -
Building on top of the saql you've provided, use bindings for targeting filtering. Say you want to filter result of a query called 'salesTerritory_1'. Then your binding can potentially look this -
q = filter q by {{column(listSelectorStep_1.selection, [\"locationFilter\"]).asEquality('City')}} || {{column(listSelectorStep_1.selection, [\"locationFilter\"]).asEquality('State')}};Hope this help!