Highlight weekends in Tableau in line plot with bands - data-visualization

I have the following question!
I have a line plot showing my completed applications per day.
I want to highlight weekends in a band like the picture below(It's from a plot on excel i think):
I have already create a metric which is:
IF DATEPART('weekday',[Order Date]) =1 OR DATEPART('weekday',[Order Date]) = 7
THEN "Weekend" ELSE "Not Weekend" END
But i don't know how to include that so i make a band with it.
Any help would be high appreciated! Thank you!

I have done it like this..
Data - sample superstore
I have added one calc field, where 12000 is max value of my sales value for a given view
IF DATEPART('weekday',[Order Date]) =1 OR DATEPART('weekday',[Order Date]) = 7
THEN 12000 END
Adding this field to view (dual axix) and tweaking a little, I got
The only problem I see here that there are no bars where no order has been placed on weekends.
This however works perfectly where there are no nulls on dates like in your data. see working on my sample data.

Related

Display all dates even if there is no data

I am attempting to display all the dates within a range even if they do not have data for the particular date.
Our employees do work 24/7 365 ( like everyone else) so there are dates within my time range that wont pop up. What i have tried is to add and exception that states even if the date has a null to display that particular date.
Currently i have a crosstab with the row being the numbers of items completed and the columns being the date that the item was completed.
For a visual:
04/01/19 04/02/19 04/03/19
1 2 3
I would like to continue that till the end of my range (the month) but my data skips if nothing was completed for that date.
What i currently have:
04/01/19 04/04/19 04/05/19
1 6 8
For the rows I have this in the formula bar for my row.
If [Items Completed]> 0 Then [Items Completed)] Else 0
For the columns I have this in my formula bar
If IsNull([Completed Date]) then 0 Else [Completed Date]
Thinking this would give me a 0 in those columns where nothing was done.
You need to create a variable and use the TimeDim function like this...
All Dates = TimeDim([Completed Date])
Then replace [Completed Date] in your table with the [All Dates] variable. You can name it whatever you want. This will result in blank values for the dates for which you do not have data. If you want to have zeroes display for the dates with no data you can apply a custom format setting "Undefined" to "0".
You can find a more thorough explanation with possible variations here.
Enjoy!
The TimeDim method was the basis for me achieving what I needed - namely a line chart that displayed zero values if no one had completed a training course on a particular date in my range. I work in Learning Management System software so this is often required.
The object in my case is called [Course Completed Date (Success)], so here's my variable (which is a dimension, not a measure):
=TimeDim([Course Completed Date (Success)])
Note in my screenshot how the zeros and now displayed. Previously they were missing.

How to show last 13 months in X axis based on single slicer selection?

EDIT: As this is an old question, the intended solution is supported by the relative date slicer in Power BI as seen here.
I am building a rolling 13 month net revenue chart and I've came across a requirement to show the last 13 month in x axis based in what month (YYYYMM) the user selected in a YYYYMM slicer.
The chart below is the one I want:
In order to get the intended behaviour, currently I need to select each one of the 13 month in YYYYMM slicer:
Any ideas on how I can get this to work in Power BI so that the user just have to select the base month?
Thanks in advance,
Cristhian.
Let's say you have a table data(date, value).
Add a table datefilter(date) with dates you want to select. Add a slicer by this date.
Add a calculated column to data : date2 = DATEADD('data'[date].[Date],13,MONTH)
Add this measure:
current = IF(AND(
MAX('data'[date]) < MAX('datefilter'[date]),
MAX('data'[date2]) > MAX('datefilter'[date])),1,0)
filter your visualisation by current is 1.

Formatting Day Time X Axis in SSRS Charts

I am working on a SSRS report which compares data of 2 given months. I'm categorising the chart based on Day and time in the following format 1, 6:00 AM. I get this column from the T-SQL itself. But the axis does not come properly. It looks like below now which doesn't make sense. I want it to be in order from 1st to 30th with the time component.
I guess I need some kind of sorting on X-axis with respect to date time. Please help!
After deleting from sorts from chart I'm getting some extra repitive dates after comparing all 30 days of both months. Data from the query looks alright to me!
Thank you!
Ok. Large query
You X-axis are show value in format date,hh mm tt Right ?
Then you want to sort them with day number 1 - 30.
From your query I suggest you add 1 field is like this CAST(SampleCollected AS DATE) [orders] and use this field in Order in Query or Sort on SSRS (not recommend ) and if you use Order in Query must delete sort condition on chart sort.
But if result still not you want try to add MONTH(SampleCollected) As MonthG to order again like this
ORDER BY MONTH(SampleCollected),CAST(SampleCollected AS DATE)
Hope it's Help.

PowerPivot: Aggregating 'SAMEPERIODLASTYEAR' Sales by Year, Qtr etc

I've created a new measure which uses [TotalSales] and 'SAMEPERIODLASTYEAR' to calculate the previous year's sales, see below:
=CALCULATE([TotalSales], SAMEPERIODLASTYEAR(Dates[Date]))
This all works fine if I create a pivot that displays individual dates (e.g. 01/01/2015) and then the new measure 'previous year sales' value next to it. My problem occurs when I want to change the pivot and display previous year sales by year, quarter or month - with any of these options I get no sales value.
I'm using a 'Dates' table which is linked to the Sales table.
Am I right in thinking I can re-aggregate sales in this way? I have seen an error message which says something about not been able to aggregate a non-contiguous value or date.
I've had a good look to see if anyone else has experienced the same problem, but can't see anything. Any guidance would be helpful.
Regards,
Martyn
Yes you can re-aggregate in this way. Your formula is correct would handles the changes to the aggregation level.
I would check that your 'Dates' table is marked as a date table. Ensure that the year, quarter & months are in this date table and not in your Sales table. Make sure that your date table has one record for each day between the beginning of your sales data set and the end. Check behavior in Power View if you are using Excel 2013.

SSRS column and line chart?

Hello I have a simple dataset in SQL that counts meter readings... There are meter readings every day and I would like to SUM the count, display that in a column chart at a daily interval. What I would also like to do is display a cumulative count as a line so 4 orders Monday, 3 orders Tuesday, 5 orders Wednesday 4+3+5 etc. Apparently there is a running total property I read somewhere in SSRS? Does anyone know how to do this? I'm stumped! I currently have a SUM of count as my total value with category group of date read but it does not seem to be displaying properly. Instead of saying 5 orders on tuesday, it is just showing 1,1,1,1,1 etc...
SELECT COUNT(readingId), dateRead
FROM Readings
WHERE (dateRead BETWEEN #StarDate AND #EndDate) AND (webcontactid IS NOT NULL) AND (meter = 1)
GROUP BY Readings.dateRead
I created a bar chart, put dt as Category group, added a fake Series group called g1 (Group by "A"), and used two data fields, one with the expression
=Sum(Fields!NReadings.Value)
and one with the expression
=RunningValue(Fields!NReadings.Value, Sum, "g1")
and set this to appear as a line.
I got this on SSRS 2005, but I hope it helps for 2008. If anyone has a way to do this without creating a fake Series, then please let me know.