Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Dynamic Filter or Join based on Different Columns and Values

tj
7 - Meteor

I have 2 tables to work with.

 

First table contains product and sales information separated by region/country as shown below

ProductRegionCountrySales
ANorth AmericaUnited States1000
ASouth AmericaBrazil1500
AAsiaJapan2000
BNorth AmericaUnited States350
BEuropeGermany500
BAsiaSingapore360
BAfricaSouth Africa800
CNorth AmericaCanada450
CEuropeFrance950
CAfricaKenya200

 

Another table is condition table based on region/country as follows

LevelDetails
Global 
RegionalAsia, Africa
CountryUnited States, Germany

 

What I want to achieve is either use filter (preferred) or join to dynamically subset product table based on condition table specific row. 

  • Global - do NOT filter anything
  • Regional - filter all Asia and Africa product sales
ProductRegionCountrySales
AAsiaJapan2000
BAsiaSingapore360
BAfricaSouth Africa800
CAfricaKenya200
  • Country - filter all US and Germany product sales
ProductRegionCountrySales
ANorth AmericaUnited States1000
BNorth AmericaUnited States350
BEuropeGermany500

 

Ideally I'd like to use filter tool with condition can be updated dynamically, alternative would be join (but not sure how to do with global level). 

 

I researched various community posts, including macros, control parameters, dynamic filter/join, etc., but still not able to wrap my head around for an elegant solution.

 

Much appreciate your thoughts and ideas!

6 REPLIES 6
Greg_Murray
12 - Quasar

@tj 

 

Take a look at this. I am not sure exactly how you expect the output, but I think this is a start. 

 

Greg_Murray_0-1603135838279.png

 

tj
7 - Meteor

Hi @Greg_Murray 

 

Thanks a lot for your quick help, the output seems to work as intended. Append and filter tools did the trick!

 

One thing I'm not certain is how well it would perform for large dataset (i.e. million rows) which would append each condition to every row.

 

I'll test out your solution to see how it works, and would be curious to see if there's other solution available to dynamically update filter condition without appending/join the tables.

 

Thanks again for your insights!

Greg_Murray
12 - Quasar

Hey @tj , 

 

Alternatively you could take an iterative approach to filtering each set of conditions with a batch macro. See attached. This one is a little trickier. It creates the expression for each condition and then dynamically updates the XML in filter tool to in the batch macro. This should be more performant at scale.

 

Greg_Murray_0-1603142261642.png

 

tj
7 - Meteor

Excellent, thanks @Greg_Murray 

 

Will try out this week and report back which one works better.

 

Thanks!

tj
7 - Meteor

Hi @Greg_Murray,

 

I tested solution #1 and it's working as intended, I went ahead to mark your #1 solution.

 

A couple of questions on the solution:

  1. If I have multiple condition, i.e. one is global/region/country, another one is department/function, etc. Am I able to construct filter statement to have OR condition within while AND condition across?
  2. Is there a way to pass file value (Asia, Africa) to value IN statement, instead of split into row and append by each? I'm struggling to make it work as IN doesn't seem to take the value correctly (even after adding " or ")

 

Much appreciate your response!

Greg_Murray
12 - Quasar

Hi @tj,

 

Based on what you're saying I think the second solution is more in line with what you want. You should be able to create expressions with multiple conditions to meet whatever requirement you want. 

 

Greg

Labels