Hi Tableau community,
I am fairly new Tableau user. I just created a calculated field for "current month sales"
{ SUM(if YEAR([Order Date]) = {MAX(YEAR([Order Date]))} AND
MONTH([Order Date])=Month({max([Order Date])})
THEN [Sales]
END)}
I added a filter for "Type of Customer" (Domestic or International). However, when I edit the filter to be only "International" the calculated field continues to calculate the total sales for Domestic + International. I am not certain if I have to "hard code" the filter in the calculation and add a value such as:
[Type of Customer] = "International"
However, this will not be ideal since I want to be able to go back and forth between selecting "Domestic" or "International" and being able to see exactly the values I want. Let me know your thoughts and if you can help with this one.
good morning @Guillermo Trevino your formula is going to return the sales for the entire month of the latest date in the dataset -
if I understand you want to add a filter to the viz so you can only see the International (or domestic ) sales
You can do that by placing the [type of customer] into Context
filers applied to dimensions in Context (step 3 in the order of operation) are filtered before the LOD is calculated (step 4) - Dimension filters ( step 5) are applied after the lods are calculated - in that way you can control when filters are applied
see https://jimdehner2.blogspot.com/2020/06/faq-series-context-filters-what-do-they.html to see examples of using context filter
If this posts assists in resolving the question, please mark it as “Best Answer” or Upvote.
Also please help use better track your reply by including a mention to the volunteer who provided the answer – mine is @[Jim Dehner]
Thank you.
Jim