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
666 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 ffdfd
• 5,550 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
2,723 views
0 votes
1 answer

How to fix spelling error in a field or column value using Tableau?

You should be able to use a ...READ MORE

answered Mar 10, 2022 in Tableau by Neha
• 9,020 points
770 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
9,891 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
1,369 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
1,594 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 ffdfd
• 5,550 points
1,183 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 ffdfd
• 5,550 points
1,170 views
0 votes
2 answers

Calculation issue: Distinct sum in Tableau

I feel the easiest way is to ...READ MORE

answered Aug 26, 2020 in Tableau by Dhiraj Kumar Sahu
9,595 views
0 votes
1 answer

Issues with the Range value in Tableau

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

answered May 9, 2018 in Tableau by ffdfd
• 5,550 points
1,220 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 10, 2018 in Tableau by ffdfd
• 5,550 points
1,551 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP