7 Replies Latest reply on Oct 18, 2013 6:25 AM by Prashant Sharma

# compare a column by date field(another column)

Example:- A sheet has two columns date and columnA , i want to compare the columnA values for '5-Oct-13' to '9-Oct-13' and return the number of matching counts.

• ###### 1. Re: compare a column by date field(another column)

Hi sneha,

You can use the following formula:-

if [Date1]==[Date2] then [Number of Records] end

This will give you the count of number of records when both are same.

Warm Regards,

Prashant Sharma - India | LinkedIn

• ###### 2. Re: compare a column by date field(another column)

Hey Prashant, thanks for the reply .but i have only one column  for date,

data looks like:-

date                              columnA

05-OCT-13                    sa

05-OCT-13                    re

05-OCT-13                     sa

05-OCT-13                    ga

09-OCT-13                      pa

09-OCT-13                         sa

09-OCT-13                         re

10-OCT-13                         sa

10-OCT-13                             re

Suppose user wants to compare columnA data for '05-OCT-13' and '09-OCT-13 ' then it should return 2 (distinct count of column A matching string ).

I am a sql person:- in db i would do something like this:-

select count(distnct t1.columnA) from

(select columnA from table where date = '05-OCT-13') t1, (select columnA from table where date = '09-OCT-13') t2

where t1.columnA = t2.columnA;

Want to replicate the same thing in tableau

• ###### 3. Re: Re: compare a column by date field(another column)

Hi Sneha,

I was busy from past 2-3 days so couldn't reply. Here is the packaged workbook of your solution & the excel file which i used to create this workbook.

Warm Regards,

Prashant Sharma - India | LinkedIn

• ###### 4. Re: compare a column by date field(another column)

Hi Prashant,

Actually i wanted to compare the columns internally. finally i resolved to using parameter based sql which works fine.

thanks anyways

• ###### 5. Re: compare a column by date field(another column)

Hi Sneha,

Yes in Custom Sql you can use parameter. I created that parameter without using Custom Sql & with the help of calculated field achieved the same, but both the ways are correct.

Warm Regards,

Prashant Sharma - India | LinkedIn

• ###### 6. Re: compare a column by date field(another column)

thanks Prashant ..Got your approach.. Performance should be better with your approach i guess

• ###### 7. Re: compare a column by date field(another column)

Yes, performance is better if you do not use Custom Sql but if you are good in Sql then you can use it.

Warm Regards,

Prashant Sharma - India | LinkedIn