4 Replies Latest reply on Mar 12, 2013 12:09 PM by Mark Holtz

# How can I get a old month using a tableau function?

I need to calculate a field getting the old month from another field, for example:

Field 1 - Money =  333
Field 2 - Month/January =  444 - Month/February = 555 - Month/March = 666

However, I want to calculate like this: "Field 1 / Old Month from Field 2"

How can I do it?

• ###### 1. Re: How can I get a old month using a tableau function?

Hi Jonathan,

I'm not sure what you mean by "old month." Are referring to the previous month of the current value? Is your Month field a datetime data type?

e.g.,

 Month Value 1/1/2013 300 2/1/2013 400 3/1/2013 500

Are you asking how to generate a calculation to give 500/400 as the Month-over-Month change in 3/1/2013?

• ###### 2. Re: How can I get a old month using a tableau function?

Hi Mark,

Thanks by atention

No. I wanted tell about previous value. I gotta four fields, one field must be calculate with another field.

For example below, look this!

 january february march april may june july august september october november december FIELD 0 0,076759822 0,073104593 0,070784774 0,066205888 0,073438479 0,075748329 0,077489975 0,06921599 0,061454322 0,063313647 0,060511877 FIELD 1 -32949 -32162 -32270 -30614 -34098 -35623 -36833 -34476 -31519 -33791 -33273 -31208 FIELD 2 429248 439945 455889 462406 464307 470281 475326 498093 512885 533708 549859 570808 FIELD 3 429248 439945 455889 462406 464307 470281 475326 498093 512885 533708 549859 0

I need to do a calculate between "FIELD 1" and "FIELD 2" because a need to show a result in percent format into
the "FIELD 0". However, the calculate have make like that: "FIELD 1 / previous month from FIELD 2" or "Value FIELD 1 month december / Value FIELD 2 month november"

I try to do it but I can't help it.

Whether you still not understood, please tell me!

Many thanks!

• ###### 3. Re: How can I get a old month using a tableau function?

Jonathan,

I think you're looking for the LOOKUP() function.

I transposed your data into a source.  I still don't understand what Field 0 is because it is not Field 1 / previous Field 2... in other words, the last column does not match the first column.  The workbook I attached accomplishes this in Tableau, but I may still not have what you're after entirely right.

Because LOOKUP is a table calculation, you must be sure to use the right partitioning and addressing, in this case, the month field.

 Month Field 0 Field 1 Field 2 Field 3 Result january 0,076759822 -32949 429248 429248 february 0,073104593 -32162 439945 439945 -0.07493 march 0,070784774 -32270 455889 455889 -0.07335 april 0,066205888 -30614 462406 462406 -0.06715 may 0,073438479 -34098 464307 464307 -0.07374 june 0,075748329 -35623 470281 470281 -0.07672 july 0,077489975 -36833 475326 475326 -0.07832 august 0,06921599 -34476 498093 498093 -0.07253 september 0,061454322 -31519 512885 512885 -0.06328 october 0,063313647 -33791 533708 533708 -0.06588 november 0,060511877 -33273 549859 549859 -0.06234 december -31208 570808 0 -0.05676

Hope this helps.

• ###### 4. Re: How can I get a old month using a tableau function?

Great!!!

It worked out all right!!!
Thank you so much. I saw your example using LOOKUP, it's exactly that I needed.

Thanks again. Bye