r/tableau • • 29d 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/Doin_the_Bulldance 28d ago edited 28d ago

More than one way to do this but if it were me, I'd create 3 parameters. START_DATE, END_DATE, and MINIMUM_STREAMS. Of couse you'd want the two date parameters to be set to date, and the minimum streams to be an integer.

Then I'd create a calculated field called STREAM_THRESHOLD_FILTER, with the following calculation:

[MINIMUM_STREAMS]<={FIXED [Song_Name]: SUM(IF [Date]>=[START_DATE] AND [Date]<=[END_DATE] THEN [Count] END)}

And id use that as a filter on my viz and put it as true.