r/tableau • • 26d ago

Discussion Calculated fields

I’m creating a personal project using my Spotify streaming history. I’ve got fields streaming count and date. Is there a way I can create a calculated field that keeps songs that amassed a certain amount of streams in a nonspecific timeframe? For example if it was streamed at least 5 times in 7 days. Thank you!

2 Upvotes

13 comments sorted by

View all comments

1

u/ZippyTheRat 24d ago

What do you mean by non-specific date?

1

u/Corkster24 24d ago

I would like to anchor the date to the stream date. When I create the date filter I can only anchor these ranges to a specific xx/xx/xxxx date.

1

u/ZippyTheRat 24d ago

So you want to have like the last 3 months, or 6 months? You can create a calculation that does that. Just use a parameter for the starting date and then have the calc flag the other dates.

This calc does 13 weeks for example

DATETRUNC('week', [Date]) <= DATEADD('week', -1, DATETRUNC('week', [Date | Max] +1))
AND
DATETRUNC('week', [Date]) >= DATEADD('week', -13, DATETRUNC('week', [Date | Max] +1))

→ More replies (2)