Manolo Eschmann
Manolo Eschmann

Reputation: 1

Tableau Calculated Field of Running Average for the last month

Hey Guys I am trying to do a calculation for a Running Average over the last month in a calculated field in Tableau. However I struggle with defining the last month range and adding it to the calculation. I thought of using

IF [date] >= DATEADD('month', -1, TODAY()) THEN 
                                       RUNNING_AVG(SUM( IF [Entry Type] = 'Sale' 
                                       THEN [Invoiced Quantity]
                                       ELSE 0
                                       END )) END

However this is not working at all. I hope someone can help me out. Cheers

Upvotes: 0

Views: 864

Answers (2)

Omur
Omur

Reputation: 138

You do not have to write this into calculated field. Just filter date column and set that to be always filter for last 30 days, or last month. Then, use "calculated field" section just for calculation independently from the "date" which is already considered in filter section. enter image description here Good luck

Upvotes: 0

Manolo Eschmann
Manolo Eschmann

Reputation: 1

This worked out:

(SUM( IF [Entry Type] = 'Sale' AND [Posting Date] >= DATEADD('month',-1,TODAY()) THEN [Invoiced Quantity] ELSE 0 END ))

Upvotes: 0

Related Questions