tableau / TabPy

Execute Python code on the fly and display results in Tableau visualizations:
https://tableau.github.io/TabPy/
MIT License
1.57k stars 599 forks source link

Measure from previous month shown in this month #505

Closed Jeromevb closed 2 years ago

Jeromevb commented 3 years ago

I am looking to write a script or function that takes a measure and shows the sum of this measure from month-1 in month0.

For example: I want to create a calculated field that returns the sum of sales from December 2020 to be shown in January 2021. From January 2021 to be shown in February 2021, etc. etc. etc.

I am using latest version of Tableau and TabPy. I am new to using TabPy.

nmannheimer commented 3 years ago

Hello, I think what you’ll want is actually the LOOKUP() function in tableau:

https://help.tableau.com/current/pro/desktop/en-us/functions_functions_tablecalculation.htm#lookupexpression-offset


From: Jeromevb @.> Sent: Tuesday, May 25, 2021 8:47:46 AM To: tableau/TabPy @.> Cc: Subscribed @.***> Subject: [tableau/TabPy] Measure from previous month shown in this month (#505)

I am looking to write a script or function that takes a measure and shows the sum of this measure from month-1 in month0.

For example: I want to create a calculated field that returns the sum of sales from December 2020 to be shown in January 2021. From January 2021 to be shown in February 2021, etc. etc. etc.

I am using latest version of Tableau and TabPy. I am new to using TabPy.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/tableau/TabPy/issues/505, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AF3LTXNDIKOBS4LDTO6JQOTTPOTAFANCNFSM45PNDTEQ.

Jeromevb commented 3 years ago

Hi nmannheimer, thanks for your reply.

I am indeed looking for the outcome represented by the LOOKUP()/PREVIOUS_VALUE function. The only problem I am running into is that I don't want to show or hide the last month in the table. For example I want to show values in January, February, March. Based on Sales in December, January, February, but I don't want to show/hide the month December in the view. Is there a solution for this?

nmannheimer commented 2 years ago

This is out of scope for the TabPy github and a better question for Tableau support so I'm going to close.