
1. Re: adding distinct to tableau generated query
Joshua Milligan Apr 2, 2013 5:00 AM (in response to hari.nalajala)Hari,
I'm not sure I exactly follow what you want. In a sense, you are getting the distinct values for any dimension that you place on the Row or Columns and then an aggregation of any measures. The actual query generated by Tableau is more likely a GROUP BY instead of SELECT DISTINCT  but ultimately the result is a distinct list of dimension values.
But maybe I'm not understanding your requirement. If so, can you provide an example?
Regards,
Joshua

2. Re: adding distinct to tableau generated query
hari.nalajala Apr 2, 2013 6:58 AM (in response to Joshua Milligan)Thanks Joshua.
I have multiple tables in my query and I need to get the distinct of the result set (I do not have a way to bring in unique records using joins because of the nature of the data I am dealing with) before Tableau can apply group by in order to avoid double counting of some of the measures.
I am bringing in results at most granular level in order to support my other count(distinct) calculations in the same report.
Please find sample data and expected result below.
Sample Data Contact_ID Indiv_id MRR division 1 111 $50 Div1 1 111 $50 Div1 2 112 $40 Div1 3 113 $30 Div2 4 114 $20 Div3 4 114 $20 Div3 Need to get distinct rows from above data and then sum MRR across distinct rows Expected Result MRR Division MRR Div1 90 Div2 30 Div3 20 Regards,
Hari

3. Re: adding distinct to tableau generated query
Jonathan Drummey Apr 2, 2013 11:38 AM (in response to hari.nalajala)Hello Hari,
See the attached. I created a calculated field called "WS Avg MRR" using the formula WINDOW_SUM(AVG(MRR)) with some optimizations. The view is set up with division on Rows, with Contact_ID, and Indiv_id (i.e. all the other fields that define a distinct "row" in the data) on the Level of Detail Shelf. Then the WS Avg MRR field is set up with an Advanced... Compute Using of division, Contact_ID, and Indiv_ID on the righthand side of the Advanced dialog, with Restarting every set to division.
This causes Tableau to create a "set" of the distinct values of the three fields, and restart the partitioning for each new value of division.
Jonathan