I have two datasets (Data A and Data B) which I am joining in Tableau. After joining the datasets I need to sample the data for each cond (cond1 and cond2 below) based on following rules and tag sample in a calulcated field named as RandomSample.
if Date > Date 1 and cond1 = Y then randomly sample 40% of the population.
if Date > Date 1 and cond2 = Y then randomly sample 10% of the population.
Now, If you will look at the final dataset in the end under expected result. It has Random sample column. For cond1, B,C,G,H all have Y in Cond1 and date > date 1. So we do a 40% sample of 4 which is 1.6. Round it to 2. So we tag b and g as Y in Random sample column.
For cond2, D and E have Y in cond2 and Date > Date 1. Here we do a 10% sample of 2 which is 1. So we tag e as Y in random sample.
My question is how do I create this sampling calulcated field RandomSample in tableau? I have attached a test workbook below. I know how to do this in Oracle but I don't have both datasets in Oracle so sampling has to be done in tableau after data has been joined.
Test.twbx 11.6 KB