8 Replies Latest reply on Mar 21, 2016 5:59 PM by rahul.patel.2

# How do i display Last 7 days and Last 30 days Sales ?

Hi All,

I have a request from user that they need to see Sales of last 7 and 30 days feom current date(Today) along with its percent change from last 7 and 30 days from current date (Today).

Have posted a screenshot which will give an idea on what i am trying to get.

The Tableau version i am using is 9.2.

Can you help me out with this?

Thanks for your help.

• ###### 1. Re: How do i display Last 7 days and Last 30 days Sales ?

Hi Rahul,

Can you also share a sample data. I understood what you are trying to get but not from what you are trying to get this. Also what will be calculation for Percentage Change. This change is with respect to what, what's the numerator and denominator you are using?

-Amanjot

• ###### 2. Re: How do i display Last 7 days and Last 30 days Sales ?

Hi Amanjot,

sorry but i cannot share the data i taught of giving you the sample superstore subset but the data is not wit current date .

The last 7 days sales is the running total of all 7 days and same for last 30 days sales.

For percent change is total sales of 7 days compared to previous 7 days sales and same for 30 days.

Any idea on how we can do it ?

Thanks.

• ###### 3. Re: How do i display Last 7 days and Last 30 days Sales ?

Hi Rahul,

I don't have tableau with me right now but still try this calculation if you can this should help. I'll check it in my tableau later and post if there is any issue.

[Last 7 Days] = SUM(IF TODAY() - ATTR([YOUR DATE FIELD]) <= 7 THEN [SALES] ELSE 0 END)

[Last 7 Days % Change] = [Last 7 Days]/SUM(IF TODAY() - ATTR([YOUR DATE FIELD]) >7 AND TODAY() - ATTR([YOUR DATE FIELD]) <= 14 THEN [SALES] ELSE 0 END)

[Last 30 Days] = SUM(IF TODAY() - ATTR([YOUR DATE FIELD]) <= 30 THEN [SALES] ELSE 0 END)

[Last 30 Days % Change] = [Last 30 Days]/SUM(IF TODAY() - ATTR([YOUR DATE FIELD]) >30 AND TODAY() - ATTR([YOUR DATE FIELD]) <= 60 THEN [SALES] ELSE 0 END)

-Amanjot

1 of 1 people found this helpful
• ###### 4. Re: How do i display Last 7 days and Last 30 days Sales ?

Let me try this out but please do upload the tableau workbook for this calculation.

Thanks

• ###### 5. Re: How do i display Last 7 days and Last 30 days Sales ?

Hi,

Any Chance to upload the  sample file.

Thanks

• ###### 6. Re: How do i display Last 7 days and Last 30 days Sales ?

Rahul -- What Amanjot offered is just pseudo-code.

If you uploaded a workbook that simulates what you are doing, people can help out with your actual example.

You can anonymize your data as shown in the following thread:

Amanjot could probably hack up an example to demonstrate that suggestion, but you are asking the other person to do the effort that you should be doing.  You need the help, so you should be doing the prep work for supplying the workbook and data where the solution will be demonstrated.

• ###### 7. Re: How do i display Last 7 days and Last 30 days Sales ?

Hi Rahul,

Just checking if that calculation worked for you. If not like Joe mentioned please share a packaged workbook as i didn't aply this code in workbook it just wrote it for you.

-Amanjot

• ###### 8. Re: How do i display Last 7 days and Last 30 days Sales ?

Hi Amanjot,

The calculation that you provided helped me out had is correct.

Thanks for you help sorry for late reply.

Thanks again