How is it possible to calculate value for the same day last week in tableau for every day? - tableau-api

I would like to calculate values for yesterday for every date in a table.
Firstly I have simply calculated the number of orders for each date using COUNTD function.
But afterwards I encountered some problems trying to calculate values for "yesterdays".
Please refer to the image
example
For example for 12th of April I would like to obtain the value for 11th of April.
On the internet there are a lot of examples using today() or max() or table functions but they do not give the required result because a would like to filter for example 12th April but still see the value for 11 April.
Could you please help, how is it possible to do this?

Related

Power BI - Calculating a price/cost until a variable end date

Let's say I have a table of projects/programs/subscriptions/etc, it doesn't really matter as long as there is a price or cost per some amount of time. My table includes at least the following columns:
[ProjectName]
[StartDate]
[EndDate]
[CostPerDay]
I'm trying to allow the user to choose another date (slicer I assume?) and display the cost of each and all projects up to that date. Is this possible?
Edit: After the first responses I realize the original question was very poorly worded. Sorry about that. I've reworded it and I'll explain more here:
I am not trying to filter the programs by end date. I'm trying to sum a cost up until the end date OR slicer date, whichever is earlier.
Here's a short example table:
So we can also think of it as a Gantt chart like this:
Now imagine sliding a vertical line along that chart. I want to see the total cost up to that date.
I'm sure it will have to do with counting days between start date and the slicer date, then multiplying by cost. But how do we not include days after the end date of each project? Or it may be easier to do a range slicer with a min and max date, but again not counting days before or after each project.
To word it differently: can I input a date range, count the days that each project has in common with that range, and (the simple part) multiply days by cost?
It looks like what you need is a table visualization with a slicer for End date. Once the table and slicer are created, you can click on the small down facing arrow in the slicer and choose "Before". If you want both start date and end date in the equation, then you would have to add one more slicer for "Start date". If this is not what you are looking for kindly provide additional details so that we can help you out.

Flatline: How to calculate days between two dates

I want to add a calculated field in a BigML datasheet with the result of days between two dates.
I'm trying to figure out how to calculate the number of days between two date fields with Flatline language but I don't know how to do it even reading the doc.
Any clue about how create this calculated field?
PS: Somebody with enough reputation could create and add tags "bigml" and "flatline"?
Currently, the only way to subtract dates is by first transforming them to an
epoch (number of milliseconds since 1970) and then computing the difference:
(- (epoch "12/03/1990") (epoch "01/01/1988"))
That will give you the number of milliseconds between the two dates, which then
can be transformed to other units. What that won't give you is of course the
difference in calendar days: we don't have yet in Flatline a way of subtracting
calendar dates. But it shouldn't be too difficult to add them if it's a feature
you need :)

Formula to add days to a Gregorian date

I was looking at Tomohiko Sakamoto's weekday calculator. It's a formula to calculate the day-of-week directly given year, month, day. That made me wonder what other neat date calculation shortcuts exist.
In particular, given an input date as (in_year, in_month, in_day) and a number of days N to add, what's a formula for returning the output (out_year, out_month, out_day)? Is there a well-known trick like the algorithm above?
One way would be to convert the input to a Julian day (a count of days since 4713 BC), add N to it, and then convert back. There are formulas for conversion in both directions. But the combined formula would be quite unwieldy. Is there a simplified version?
Perhaps there is even a formula to move forward or back by a certain number of weekdays.
This question isn't "how do I do date arithmetic in my favourite programming language?" I know how to call the date library to perform these operations. It's more curiosity and the hope of starting a collection of cool date algorithms.
Some of the answers in Algorithm to add or subtract days from a date? will be relevant to this. In particular http://howardhinnant.github.io/date_algorithms.html gives code to convert y,m,d to a count of days and back again. Those two routines run back to back would be pretty fast.

Tableau : How to get the Dashboard always display the latest 10 days worth of group statistics

My input text source always contains last 12 months worth of data. e.g: Current month is October. So My input source contains data starting from last Oct 1st to till date. But I want the aggregate statistics to be displayed on a daily basis for last 10 days of sales , 30 days of sales, 45 days of sale per product across various regions
I am trying to use window_avg fuction with something like window_avg(sum(sales), first() + datediff('day', window_min(min([date]))-1, dateadd('month',1,window_min(min([Date]))-1)) * 13,13) something like that. But I am not able to crack the exact logic.
Could you please suggest me some better way to achieve this, rather than using these kind of calculations. Also I am afraid if this goes wrong if there is data missing in the middle one or two days.
Any help is appreciated.
A very simple thing is to use a relative date filter. There's a UI for you to select they last N days.
Put the date on the columns shelf and set it to the date truncation of year-month-days. Put your measure row shelf. Put the date pill on the filter shelf too and use a relative date filter.
If you are doing simple aggregate like the sum of sales for a day it's easy and you'll not need to do anything else. You can can also fairly easily create a table calculation by right clicking on the measure and choosing one of the quick table calculations. Even when I'm doing a more sophisticated calculation, I start with a quick table calculation and then start editing.
If you are doing something like a moving average, the filter and the moving average can interact. For example, if I'm showing a 5 day trailing moving average over 30 day period, the first few days do not get averaged in the same way -- you don't have days over 30 days ago. If that's not really an issue for you, that's cool and you are done.
If it is an issue, it's going to be trickier. I'd suggest creating a second filter based on a table calc. The reason is the order of operations in Tableau. The raw data is filtered then aggregated by the database, then the table calcs are performed. If there are any filters on table calculations, then they are filtered after that. So basically, in my example, you want create a filter for 35 days on the date, then create a table calc on the date -- like using the INDEX() function. Filter the index function to show 30 days worth, then you've got a moving average that uses 35 days to compute the average, but only shows 30.

Calculate Difference in Dates Google Spreadsheet

Ok so I'm not talking about calculating the difference between 2 dates in different cells. I know this may not be possible but I thought I'd ask anyway since I can't seem to find anything on it.
What I'm trying to do is setup a column that auto-calculates the difference between a date value entered into it and the current date. The purpose is to create an auto-filling point system. Where an entry receives points equivalent to the difference in due date and current date. So if someone submits a job request today, 5/30/14, and wants it back by 6/5/14 then they would receive 6 points, which is the number of days difference between now and then. However, I want this all done in a single cell, not calculating between 2 cells. I want each cell within the column to auto-calculate itself when I enter a due date, and transform the entered date value to the number of days difference.
Thanks
Try this, just subtract to get the answer in days
A1 =DateValue("12/25/2000")
A2 =Today()
A3 =A2-A1
A3 is in days. (4904)