I have four crosstabs, the first three are the 1st, 2nd & 3rd months that make up a Quarter. The fourth crosstab reflects the total of that Quarter all together. I have the ‘Month’ Dimension filtering on QUARTER(month) for the fourth crosstab.
What I would like is to have a calculated field or parameter that controls the months displayed in the first three tables dependent on what Quarter is selected.
For instance, Q1 2018 for crosstab #4 and the first three crosstabs show Jan-18, Feb-8 & Mar-18. Or when the Q3 2017 is selected then Jul-17, Aug-17 & Sept-17 is shown.
Apply the QUARTER(Month) filter from the sheet to the individual month sheets as well. This will filter all sheets to the chosen quarter.
Create calculated fields to filter the individual month sheets to single months.
a. Create a new calculated field. Name the field "!Month 1 Filter", insert the following expression, and click Ok.
DATEDIFF('month',DATETRUNC('quarter',[Month]),DATETRUNC('month',[Month]))=0
b. Create a new calculated field. Name the field "!Month 2 Filter", insert the following expression, and click Ok.
DATEDIFF('month',DATETRUNC('quarter',[Month]),DATETRUNC('month',[Month]))=1
c. Create a new calculated field. Name the field "!Month 3 Filter", insert the following expression, and click Ok.
DATEDIFF('month',DATETRUNC('quarter',[Month]),DATETRUNC('month',[Month]))=2
Filter each month sheet with its respective filter.
Related
Assume: in a google sheet the attendance to courses is logged with crosses.
Goal is to get the last attendance date of a person and add 6 months to it. ( course needs to be followed every six months ).
I've tried to retrieve the date of the last course in one column and add the +6months immediately and tried to have the +6 months in the second column, but I didn't succeed in both attempts.
See this link for example google sheet: https://docs.google.com/spreadsheets/d/10DG2I4VgTlOHJ5TG0qH4pJ5hJ9zsYuJCgRzEtuiTE60/edit?usp=sharing
=lookup("x",$B4:$F4,B$2:F$2)
Enter this formula in cell G4 and copy down the rows.
This formula looks for "x" (the attendance indicator) in cells in row 4 (columns B to F) - it's looking for the last instance. Then it returns the cell value from row 2 (the course date) of the relevant column.
=EDATE(G4, 6)
Enter this formula in cell H4, and copy down the rows.
This is pretty straightforward. It takes the date obtained from the lookup formula and adds 6 months.
Note that the lookup formula references column F. That's because as you create more courses you'll want the formula to automatically include them. So in cell F1, type something like "Don't use this column" - and then don't use that column!
Now when you add a new course, insert a new column to the left of the column headed "Don't use this column". This will ensure that the range in the lookup formula will expand to include the new column/course, and your latest attendance date will be updated automatically.
BTW, there's no guarantee that the date of the next course is a working day.
I'm trying to find a way to create a table like the one above, but instead of having columns of months I would like to have columns of MTD, QTD, YTD for all selected measure values. I created calculated fields on the [Date] field but when I try to use that it still splits the data in to separate columns of months and quarters... I'm using two data sources and they are linked on the [Date] field. If I try to put two of my calculated fields in the columns bar it just combines them like 'MTD/YTD'. How can I get them to display as separate columns?
I know this is strange because there will be overlapping data (everything in the MTD will also be in the QTD and the YTD).
I found a way to do this. I created a calculated field on the date field and assigned 'MTD' to all records from the last month. Then I assigned 'QTD' to all records from the start of the quarter to the day before the start date of the 'MTD' records. Then I assigned 'YTD' to all records from the start of the year to the day before the start of the 'QTD' records. (this way there are no overlapping records).
After that I just did a quick table calc to make each of them a 'running total' table (across).
I created parameters for the dates so the can easily be updated.
I'm new to Tableau and I'm trying to make measures from one data set dependent on a Dimension in another.
So I'm trying to link Expenditures of 2000,2012 and 2013 of one data source with year dimension which has only three values (2000,2012 and 2013) in another data source
Basically at the end I just need one Average Expenditure with its value for the corresponding years.
To link the two data sources by year, you will have to picot the table to bring it from a wide format (having each year in a separate column) to a long format (having each year in a separate row).
In Tableau go to the Data Source tab and select the three Expenditure columns, then right click on the header and choose "Pivot data".
That should bring your data in the correct format:
CountryA 2000 XXX
CountryA 2012 YYY
CountryA 2013 ZZZ
CountryB 2000 AAA
...
You might want to rename your columns to [Year] and [Expenditure] for example and you will have to create a calculated field with Right([Year], 4) to get only the year out of your former field name.
Now you can click on "Data" in the menu on the top and select "Edit Relationship", there you can choose the field with the year in one data source and the newly created calculated field in the other data source.
I have a date parameter which has a week split.
When I select Week 4 I need 4 bars(one for each week viz Week1, Week2, Week3, Week4) in a chart with sum of sales data.
When I select Week 3 I need 3 bars(one for each week viz Week1, Week2, Week3) in a chart with sum of sales data
and so on ...so when I select Week 1, i will have just one bar in my chart.
I tried using DATEDIFF with last() but I am not able to control the number of bars in the bar chart
Here is what works for me:
Create a parameter based on your date field, call it timeframe (or whatever), Data Type: Date, allowable values: all
Create a calculated field with the following formular
If [Date] < [Timeframe] then [Value] ELSE null END
with [Date] being your date field and [Value] being the original measure you want to display
Use the new calculated field instead of the original measure in your graph
Right click on the created parameter and choose " Show parameter controls"
Now when you change the date in the parameter controls, the amount of bar charts will adjust that only the weeks up to that date are displayed.
It should look like this:
Edit:
If you wanted an "All" option, you could go to the parameters settings, choose "List" as the "allowable Values" and add the values from your date field.
You then just create an additional item manually with the Value of "01/01/2011" or any other date far in the future) and Display as "All".
However this will only work if you have static data! If you update your source and new, more recent values were added, they will not appear in the list since you specified explicitely which values to be available.
I also realized the following:
If you do it like I explained, you will be able to choose particular days, that might lead to different graphs for different days of the same week. Ie if I choose tuesday orfriday of the same week, I will have different sized bars although the sales of the whole week stay obviously the same. If that is alright for your use case, go for it. Otherwise you should create another calculated field with DATETRUNC("week", [date]) and use that for the paramter and calculation. With that you can only choose the week, so no matter which day of a week you choose the bar will always have the same height.
I need an expression to take an existing column and recreate this column over and over before another column/s where the column name contains either "Monday" or the date of the column falls on Monday.
The reason I need this expression is to repeat a header column in a pivoted report that is pivoting start/enddate parameter. So if a user selects to run the report for this month, they should get 31 columns (for each date/day) and header repeating before every Monday.
Make sure your dataset contains all the dates in your date range. If not create a date table and cross join to it. Don't pivot the results, let SSRS do that bit. Once your dataset has all the dates, you can use a matrix in your report and drop the date colum into the column group. This will give you one column for each date in your dataset. I'm not at my PC at the moment but if you need any more help, show an example of your dataset and I'll put together a quick sample report.