How to add a Reference Line to a row chart in Tableau that calculates from previous time periods? - graph

I'd like to create a row chart that shows sales by product where aggregate sales is the length of the row and product is each row. The data is filtered for only the current quarter.
However, I'd like to add a reference line that shows what the average sales by product was for the previous 4 quarters.
However, after reading Tableau's documentation, it seems like this cannot be done with a parameter, but with a different procedure as stated below
You cannot select a measure that isn't currently in the view as the
basis for your reference line. If you want to use such a measure,
close the Add Reference Line, Band, or Box dialog box and then drag
the measure from the Data pane to the Details target on the Marks
card. Change the measure's aggregation if necessary. This will not
change the view, but it will allow you to use that measure as the
basis for your reference line. Now re-open the Add Reference Line,
Band, or Box dialog box and resume at step 1, above.
However, after adding the measure from the Data pane to the Details target, the measure is being impacted by the filter and only showing the average for the current quarter. How can I have this reference line show the average of the previous four quarters?

First of all, you need to understand that if you have a date filter for the first quarter, you won't have the previous quarters available - because, well, your filter says that you only want the data for the first quarter.
What I would suggest is filtering the previous four quarters and adding the filter for the current quarter directly in the field (formula). The formula would be:
IF DATEPART('quarter',[Date]) = DATEPART('quarter',TODAY())
THEN [Sales]
END
Here follows an example image from a test data source: you would only need to change from text to bar and remove the original "Sales" field (that I left so you could see the difference). After that, you could use the original field (be it as a SUM or AVG) to get the previous quarters.
Edit: Here follows another take you could have in this view. Without using reference lines, now that you have two fields you can easily use both of them in the same view using dual axis (remember to sync them).

Related

"Calculated columns cannot contain volatile functions like Today and Me" error message on Sharepoint

I try to add a new calculated column to sharepoint list that will show elapsed day. I enter name and write a formula like;
=ABS(ROUND(Today-Created;0))
The data type returned from this formula is: Single line of text
When I want to save I get an error like
Calculated columns cannot contain volatile functions like Today and
Me.
Calculated Column Values Only Recalculate As Needed
The values in SharePoint columns--even in calculated columns--are stored in SharePoint's underlying SQL Server database.
The calculations in calculated columns are not performed upon page load; rather, they are recalculated only whenever an item is changed (in which case the formula is recalculated just for that specific item), or whenever the column formula is changed (in which case the formula is recalculated for all items).
(As a side note, this is the reason why in SharePoint 2010 you cannot create or change a calculated column on a list that has more than the list view threshold of 5000 items; it would require a mass update of values in all those items, which could impact database performance.)
Thus, in order for calculated columns to accurately store "volatile" values like "Me" and "Today", SharePoint would need to somehow constantly recalculate those column values and continuously update the column values in the database. This simply isn't possible.
Alternatives to Calculated Columns
I suggest taking a different approach entirely instead of using a calculated column for this purpose.
Conditional Formatting: You can apply conditional formatting to highlight records that meet certain criteria. This can be done using SharePoint Designer or HTML/JavaScript.
Filtered List views: Since views of lists are queried and generated in real time, you can use volatile values in list view filters. You can set up a list view web part that only shows items where Created is equal to [Today]. Since you can place multiple list view web parts on one page, you could have one section for today's items, and another web part for all the other items, giving you a visual separation.
A workflow, timer job, or scheduled task: You can use a repeating process to set the value of a normal (non-calculated) column on a daily basis. You need to be careful with this approach to ensure good performance; you wouldn't want it to query for and update every item in the list if the list has surpassed the list view threshold, for example.
I found some conversations about this issue. Many people suggest to creating a new Date Time column, visible is false, default value is Today's Date and it will be named as Today. Then we can use this column in our formulas.
I tried this suggestion and yes error is gone and formula is accepted but calculated columns' values are wrong. I setted column Today is visible and checked, it was empty. Default value Today's Date was not working. When I looking for a solution for this issue I deleted column Today carelessly. Then I realized calculated columns' values are right.
Finally; I don't know what is trick but before using Today keyword in your formulas if you create a column named as Today and after your formula saving if you delete Today column, it is working.
UPDATE
After #Thriggle's answer I realized this approach doesn't work like a charm. Yes, formula doesn't cause an error when calculated column saving but it works correctly only first time, in the next day the calculated column shows old values, because its values are static as Thriggle explained.

How to list unique values of a particular field in Kibana

I am having a field named rpc in my elasticsearch database and I am displaying it using Kibana. When I search in search bar of kibana like:
rpc:*
It display all the values of rpc field but I want to have only those value to be displayed which are unique.
I have been playing around with Kibana4 since a couple of weeks now. I find it intuitive and simple and the experience has been great till now. Following your question, I tried getting unique results via a Data Table visualization. Why? Because I personally find it easier to understand. Following are the steps:
1. Get unique count
Create the visualization (Visualize -> Data Table). First lets get
the count of how many unique entries we have for a particular field
(We will use this in the later part for verification). I'm using
clientip.raw but as I see, it will work just fine with any friendly
field name too.
2. Set the aggregation right
Set you aggregation back to count and have a Split Rows as follows. Not doing this will give you count 1 for each field value (since it is looking for unique counts) when you populate the table. Noteworthy part is setting the Top field to 0. Because Kibana won't let you enter anything else than a digit (Obviously!). This was the tricky part. Hit Apply and you'll get the results. Unique field values and the count of each of them.
3. Verification:
Going to the last page of the table, we see there are exactly 543 results. This is how I know it works.
What Next?
You save this visualization and add it to a Dashboard. There you can always check the request, query, response and other stats.
Just an addition to the above mathakoot answer.
For the user of newer version (which do not allow bucket size of 0 anymore) just set a value greater than the maximum number of result
And report the value in the Options>Per Page field
I am using Kibana 6 so the UI looks a bit different than the older answers here.
Here is what worked for me
Create a visualization from your query, I used a line graph type (don't think it matters)
Under Data, set metrics aggregation = "Unique Count" and set field to your field.
Set x-axis aggregation = "Terms" and set field to your field.
Set Size > your number of records
Under Metrics and Axes, disable drawing of the graph, circles, and labels (this really helps the UI not lag)
Run query and then click "Inspect" and download CSV
Data
Metrics & Axes
I wanted to achieve something similar but I'm stuck with Kibana 3.1.
I simply added a panel of type "TERMS" and configured its Field = User-agent and left everything else on default values. This gave me a nice bar chart with one bar for each User-agent.

SSRS Chart Blank with DateTimes

I am working with SSRS and having trouble creating a graphical chart to display data. My dataset is very simple, as it only has one column which is a datetime field (known as CreatedOn).
My SQL query is:
SELECT [CreatedOn]
FROM [Incident]
WHERE CreatedOn > DATEADD(m,-11, DATEADD(
month, DATEDIFF(month, 0,CURRENT_TIMESTAMP), 0))
My goal is to have the query results show up in a chart and have them grouped by year and by month, as well as sorted. For example, I should be able to see that 40 incidents were created in February 2005. Those 40 incidents would be represented graphically as a single bar (it is a bar graph) with the number 40 on top (or somewhere).
My issue is that either my chart shows up completely blank, or the report fails to run. When it fails to run, the error I receive is:
the value expression for field 'CreatedOn' contains an error: conversion from string 'CreatedOn' to type 'Date' is not valid.
I have tried using SSRS expressions on the CreatedOn field, such as CDate() and FormateDateTime(). That does get the report to run, but the chart shows up blank. I would not think that the field should have to be formatted or converted in SSRS since it is already a datetime field at the database level. I have tried about 10 different combinations of groupings and sorts, but my chart always shows up blank. I have even used CDate() and so forth in the grouping and sort expressions which are a part of the chart.
How can I get my bar chart to work (a.k.a. show datetimes, grouped and sorted)?
I am going to go off the assumption:
You have more data being pulled than just the ‘CreatedOn’ field.
a. Because if you don't it will be difficult to create a chart as you have nothing else to compare it too.
If this is an accurate assumption here is an example of how to create a chart and have the data formatted by dates.
When designing a chart you need to take a lot into consideration. First I like to ensure that I have as little null data as possible. This causes charts to act wonky (at least from my experience).
Second is how the data will be represented.
We have several things to consider when we think about charts and groups.
There are Category groups, Series groups, and then the Values.
According to Microsoft: charts have a direct similarity to Matrix’s. They act the same way:
The Column groups of a Matrix are similar to that of the Category Groups in a chart.
The Row groups of a Matrix are similar to that of the Series Groups in a chart.
The Data area of a Matrix is similar to that of the Values Groups in a chart.
Setting Up the chart:
If we want the number of Incidents sorted by Year and then Month it might look something like this:
Year by Category (You can use your group by Expression here) =Year(Fields!CreatedOn.Value)
Incidents will be in the Values section =Count(Fields!Incidents.Value)
Once you have that working and showing data I would then start adding in the data for the month. Again thinking about how you want to have the data displayed. You could then add a second Grouping on the category under the other one with your month function.
Another Useful link on charts (I know this is a little older but it’s details are still relevant)
*Side Note: When dealing with dates it can be a little tricky especially if SSRS is not recognizing something as a date. Here is a useful link that I have used when dealing with dates.
Dates
I hope this helped!
The issue was that the CreatedOn date field was not being defined correctly.
My data source was defined using an expression which depended upon parameters, using the expression: ="Data Source=sql01;" & "Initial Catalog=" & Parameters!ParentID.Value. Because the dataset must be defined at the runtime of the report, I was not able to refresh fields in the dataset using the "Refresh Fields" button.
I thought that I could work around this by defining the CreatedOn field manually. On the first attempt, SSRS threw an error at runtime claiming that I was trying to convert a string to a date, which basically meant that it perceived the CreatedOn field as defined within the dataset as a string. So I then tried to use the CDate() expression in the definition of the field, but that left me with a completely blank graph.
The solution was to:
Delete all of the fields I already had defined within the dataset
Temporarily hard-code my data source to use a database (Data Source=sql01;Initial Catalog=MyDatabaseName)
Click the "Refresh Fields" button within the dataset
Go back at set the data source to the original data source I wanted which depended upon parameters.

RDLC report footer with value from "Current Record"

I don't know if its possible or not, but thought I'd ask. Many times reports need data grouping to have anchored to the bottom of the report some summary information, such as invoices. You don't want the totals shifting UPwards based on only 2 detail lines vs another with 20. I've tried working with using the Tablix bound to the data source for the output but couldn't get it quite right... It would either shift up, or force break and appear at top of following page.
So, if anyone has some ideas to help resolve that, that too would be great.
My second approach was to just use a simple report page footer. However, the overall "Report" page is not technically "BOUND" to any datasource. So, if I put a textbox in the footer and want it to show something, I can't pick "the most recent row from the datasource associated with the Tablix", it always requires an aggregate, such as
=First(Fields!SomeField.Value, "SomeDataSource" )
=Sum( ...
=Last( ...
etc...
I just want it to have whatever was the most recent... so I tried to use report variables to create one and was thinking to have it get updated per row being processed, so it always had whatever the "latest" value was and I could just dump that value at the bottom of the report.
Any suggestions to either would be great. Thanks.
I know this is an old question, but I had a very similar problem and came up with a unique solution. I had a statement that needed to have the payment slip print at the bottom of the page even if the statement line items wrapped over to another page. I solved it by:
Making all rows in the report a uniform height.
Calculating how many rows were required to fill the page (minus the height of my payment slip.
Getting the number of line items in the statement.
Calculating the remaining number of rows needed to push my payment slip to the bottom of the page.
Adding a sub-report with the calculated number of blank rows to pad out the necessary space between the line items and the payment slip.
The advantage of that approach was that I could generate bills for multiple customers, and since the padding is part of the group it would be customized for each customer's bill and bottom-justify the pay slip for each of them.
You can use a similar approach to push your "footer" info to the bottom of your page. Since it is still inside of your data group you'll have access to the data values you need as well.
In the footer you can refer to report item from report body, like this:
=ReportItems!myFooterValueTextBox.Value
The catch is that you can refer to only one report item in your footer, so you may need to add invisible footer row in your table and concatenate all your totals into one cell (myFooterValueTextBox) in that row:
=First(Fields!SomeField.Value, "SomeDataSource") + "|" +
Sum(...) + "|" + .... +
Last(...)
I used pipe as deliminator in my example, so then in the footer, I would split the string and place values in appropriate containers, like this:
=Split(ReportItems!myFooterValueTextBox.Value,"|")(0)

salesforce.com matrix reports - more than 2 columns on row headings

I need to create a donor summary report that provides total donations by donor by year.
I need to provide
name address email yr1total yr2total etc...
It looks like salesforce only allows two columns in row headings and two columns in column headings. Is there a way to work around this
Or, is there a way to use the tabular report to do the same?
TIA
If donations is a single field on the donor's record, it seems like what you're looking to do is attempt to display two columns for the same data within a report. The best way to do this (well, outside of creating a master-detail relationship with a new custom object named "Donations") would to have formula fields for each of the donation years, and calculate the donation sums in each of them. That is, as long as you have a way of calculating the year of the donation.
I believe to get the best answer, more information is needed.
Something like this? This will work if your donation is a separate object that's linked to Account (I've used Tasks & Events linked to Accounts in my example).
Create a report in "Matrix format".
Drop Account Name on the left pane, Donation's Date on the columns.
Columns will default to days. Click the dropdown in the place where I have "Created Date" and select summarizing by year (of course fine-tune to whatever you need).
Check date ranges / filter criteria etc obviously if you don't see all data.
Click Show -> Hide details.
Drop your "Donation Amount" or similar field into place where "Record Count" is displayed. Use "Sum".
Optionally deselect Show -> Record Count.
Now you're mentioning that there are only 2 columns so you probably already tried this. Well, common trick is to cheat by using a formula field that would hold your data (separated by comma maybe?). Tabular report would require you to create some helper fields (1 per year) on Account and do some kind of rollup summaries, messy.
If it's for a dashboard you could play with summary report (it can have more groups than 2) and pick chart type table on the dashboard...

Resources