6 Replies Latest reply on Jan 6, 2017 4:16 AM by kumar msbirec

# how to display odd and even months seperately by using calculated field

Hi

how to display odd month wise sales and even month wise sales by using calculated field.

Regards

Kumar

• ###### 2. Re: how to display odd and even months seperately by using calculated field

hi Kumar,

As always there are multiple ways in Tableau...this will also do the trick, with less typing!!

IF DATEPART('month',[Order Date])%2 = 0 THEN 'Even' ELSE 'Odd' END

btw the '%' is the Modulus function, which returns the remainder...and as even number divide exactly by 2 we can use this to pick up odd or even months.

2 of 2 people found this helpful
• ###### 4. Re: how to display odd and even months seperately by using calculated field

Hi SiMON,

Can we do this  by using calculated filed ?

Regards,

Kumar

• ###### 5. Re: how to display odd and even months seperately by using calculated field

Create a Calculated field (call it, say "Odd/Even Months")

Put in this formula (changing the [Order Date] for your month date

IF DATEPART('month',[Order Date])%2 = 0 THEN 'Even' ELSE 'Odd' END

this should automatically be created as a dimension, and then use it as you would any other dimension (eg in your screen shot, switch the Month([Order Date]) with the new [Odd/Even Months] and you'll get 2 columns, one for odd and one for even.

1 of 1 people found this helpful
• ###### 6. Re: how to display odd and even months seperately by using calculated field

Hi simon,

Thanks a lot for the quick resolution.

Regards,

Kumar

1 of 1 people found this helpful