I want to plot a couple of measures by months over the last three years. The plot would be divided by year. So I put year and month for columns and the measure values for rows. The year is defined as DATEPART('year', [Month Date]) and month is DATEPART('month', [Month Date]).
The plot looks like this.
The lines are broken between years. Both YEAR and MONTH are blue (discrete), but if I change them to green (continuous), the lines are connected but it looks weird.
I wonder how to make continuous lines across year?
What has happened is you have converted a date part (i.e. Month = March) to a continuous unit. What this does is simply changes March to 3. This looses the context of what the actual date is (i.e. March 2007). To change this right click on the date field on the column. You will see two separate areas to format the dates i.e. there are two years (2015, 2015), two quarters (Q2 and Q2 2015) etc. The first is a date part and the second is truncated date from the original date/timestamp.
You want to change the format to the second Month option (Month May 2015) and ensure the data type is continuous.
This should give you a continuous line across the year. If not screenshot me where you get to and I can assist from there.
Check if the last week and first of the next year is the same, I have a similar issue and solved it by passing the dates as Day-Month-Year.
Related
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?
I’m trying to figure out how to create rolling 7 day periods. I have horizontal bar charts that are currently grouped by week, but I actually want them to be grouped by 7 day periods instead.
I used the Superstore data as an example. The top row in this image should be the last 7 days, with the latest date being in the top right, and so forth. Is this possible?
You can create a field to use as a dimension for this assuming you choose some anchor date to specify the beginning of a 7-day period. For this example, I’ll choose a literal date of July 4, 1776 but you could use the Today() function or the min or max transaction date in your data or whatever you like.
Then the DIV() and DATEDIFF() functions are all you need to calculate the number of 7 day periods Between the anchor date and the period containing [Order Date].
DIV(DATEDIFF('day', #7/4/1776#, [Order Date]), 7)
You’ll typically want to treat this field as a discrete dimension.
In the example below, I called the field [Period] and also displayed the earliest and latest dates found in the data for each Period.
In a more production oriented example, you may want to hide the header for the Period field and instead calculate the start/end dates for periods rather than draw them from the data, so that they show correctly if there were period boundaries without any transactions.
The formula to compute the [Period Start] is DATE(DATEADD('day', [Period] * 7, #7/4/1776#)) and to compute [Period End] is DATE(DATEADD('day', [Period] * 7 + 6, #7/4/1776#)) If you are going to use the anchor date in many formulas, it would be convenient to define it in one place with a parameter or calculated field.
I'm trying to recreate the following Excel-created graph in Tableau. My data has traffic organized by month-year Eg., 01-01-2016, 02-01-2016 ...etc. for each year. Would changing the data format be required, or can I work with this as is?
I'm following the tutorial here but the closest I can get is:
There are two ways to accomplish this easily.
1. Change the marks card type from Automatic to Line.
Use Show Me (upper right) and select the icon for the line chart.
Additionally, here is some information on Discrete vs Continuous Pills which cause many new users confusion.
Discrete = Distinct buckets like apples, oranges, peaches, etc
Continuous = Any values on an axis like percentage, sales, etc
For dates, discrete dates are parts of the month like days (1, 2, 3...), months (Jan, Feb, March...). A continuous date would be Jan 2019, Feb 2019, etc (these are truncated dates because they include the entire date starting from earlier in time to later in time.
In the picture, the list in green is continuous and the list in blue is discrete.
I have a report that shows a comparison of MPG a certain vehicle got from last year and this year. I want to highlight the current year's MPG in relation to whether it is greater or less than the previous year. If MPG has improved in the current year, I want the number to show green, if it is less than previous year, I want it to show red. I have two formulas that calculate the MPG, one for each year. In the Section Expert, I go to font and enter this in the font forumla:
if{#Current Qtr MPG}>={#Previous Qtr MPG} then crGreen else
crRed
However, the highlight isn't quite right. The result is that ALL the current year values have been turned green, even if they are less than the previous year and only 0 values have turned red. I suspect this has something to do with needing to reset the formatting formula at each group level, but I'm unclear on how that's done.
This may seem similar to this other post of mine, but it is different. In the first post, both values I wanted to compare were from the same field on different rows. This post is a simpler questions because I'm attempting to highlight one field based on how it compares to another separate field.
I have a cross tab with data showing clients per hour per day. So the rows are days of the week and the columns are the hours of the day, with the values being the number of clients.
Now to the main point :), I want to produce a graph for each day of the week, that shows the number of clients per hour for that day. So the report would have 8 graphs in total, one for each day and then an "all days" graph. See Picture:
Click, as I can't include pictures yet
Any idea how to do this, as I can't find a filter or anything, and the only graph I can get is all on one, with multiple bar lines for the days, in each hour block.
Ok, just figured this out :)
I have created a formula for each week day, that contains the following:
if {Command.day} = "Monday"
then {Command.kpi1}
else 0
Then in the chart expert, use this formula field for the values...so simple but overlooked :#