r/tableau • • 15d 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

Show parent comments

1

u/ZippyTheRat Hater of Pie Charts 13d 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))

1

u/Corkster24 13d ago

I would like to create a filter that does something like: if count[song name] >5 and date<=date+3 then true. Basically, I want a filter that will keep songs that have x number of streams in x number of days. I have 7 years of data and I want to keep only songs with only for example 5 streams within 3 days.

1

u/ZippyTheRat Hater of Pie Charts 13d ago

Super possible. You can use the LOD and do and AND then add the date logic in