Error: Comaparing date value with YEAR in Tableau

0 votes

I've a calculated field in Tableau which has the Years (Date Value) from a date field. When I compare this calculated field with year of another field, I get error.

IF calculated_Field = YEAR(order_date)
...

1) calculated_Field is the one created using Date value of another field.

2) Order_date is a datetime field.

Error I see in the above IF statement says "Cant compare YEAR and INT values". When I solved that using below statement, it does not work as expected as IF returns FALSE.

IF INT(calculated_Field) = YEAR(order_date)
May 28, 2018 in Tableau by James Morgan
35 views

1 answer to this question.

0 votes

You have to ensure that the comparisons are both from YEAR()

IF YEAR(another_field) = YEAR(order_date)
  1. calculated_Field is created using Date value of another_field.
  2. Order_date is a datetime field.
answered Jul 11, 2018 by Atul
• 5,530 points

Related Questions In Tableau

0 votes
1 answer

How to merge Year ,Month and date in Order Date in Tableau?

Hi, you can simply drag the Order ...READ MORE

answered Aug 24, 2018 in Tableau by AwesomeSauce
• 860 points
59 views
0 votes
1 answer

How to color code cells of a column based on the text value in Tableau

You can use the following steps to ...READ MORE

answered Mar 27, 2018 in Tableau by Atul
• 10,240 points
1,322 views
0 votes
0 answers

How can I sort date field in presence of another date field in Tableau?

Goal: Sort the new ship date in ...READ MORE

Apr 10, 2018 in Tableau by ghost
• 1,790 points
88 views
0 votes
1 answer

How to dynamically determine and categorize duplicate value in Tableau?

Apparently you define a duplicate records as ...READ MORE

answered Apr 12, 2018 in Tableau by xyz
• 1,550 points
1,402 views
0 votes
1 answer

Calculated filed with if-then

Below is the required code:  IF (NOT ISNULL([test2])) ...READ MORE

answered Mar 27, 2018 in Tableau by Atul
• 10,240 points
49 views
0 votes
1 answer

How to calculate profit when cost and revenue are in same column?

You can create the following calculated fields: Profit: SUM(IIF([account_category] ...READ MORE

answered Apr 10, 2018 in Tableau by Atul
• 5,530 points
55 views
0 votes
1 answer

Creating a calculated field with LOD expression

Go ahead and try the following three ...READ MORE

answered Apr 20, 2018 in Tableau by Atul
• 5,530 points
69 views
0 votes
1 answer

Calculation issue: Distinct sum in Tableau

SUM( { FIXED [Brand], [Market]: AVG(Target) } ...READ MORE

answered May 8, 2018 in Tableau by Atul
• 10,240 points
1,911 views
0 votes
1 answer

Issues with the Range value in Tableau

One of the best solution is to ...READ MORE

answered May 8, 2018 in Tableau by Atul
• 5,530 points
40 views
0 votes
1 answer

Is it possible to merge year, month and date in Tableau?

Remove all the date pills and drag ...READ MORE

answered May 9, 2018 in Tableau by Atul
• 5,530 points
20 views