Tableau Running Sum doesn't calculate for all months - tableau-api

My data looks like this:
Month Profit($)
June 2018 100
In my Tableau Grid, I have setup a Running Sum table calculation (RUNNING_SUM(SUM([Profit]))) to project the cumulative profit until Dec 2018.
It doesn't work if the above is the only row in the underlying data! (I want the 100 to carry over to all the future months until Dec).
But it does work, if there is are rows until Dec 2018 in the underlying data.
(I don't want to add any kind of dummy rows in my underlying data because this is a very simplified scenario and my actual scenario is way too complex to add dummy rows.)

For this we doesn't have the direct solution.
for a workaround I have created an excel sheet having the details of all the Months in a Year and connected it with the current data set as a Full Outer join.
It will give you the date field in the Dimension pane of Tableau, use that in the columns Pane and Click on Show Missing Values.
You will get the desired results.

Related

Compute rolling average across years while displaying data split by year

The dashboard in the linked workbook shows a table with sales split by year on the top. Below, there's a table with the rolling average of the last 4 weeks, including the current. It's set to show NULL if there are not enough data points. I'd like for it to compute the first January 2018 value based on the current week and 3 full weeks from the end of 2017. Carrying that concept forward, all NULLs from 2018 onward will be eliminated. The NULLs for the first 5 weeks of 2017 will be the only NULL values. The average should always be computed on a full 4 weeks (28 days) even when week 53 doesn't contain 7 days.
How can I write a calculation to achieve what's described above?
I've tried putting the WINDOW_AVG function inside a LOD, but that's not allowed. Furthermore, I've also tried using FIXED and even FIXED inside WINDOW_AVG.
Here's one of my attempts:
{FIXED [Week_int]:
WINDOW_AVG(SUM([Sales]), -4, 0)
}
It returns this error: "Error: Level of detail expressions cannot contain table calculations or the ATTR function"
Here's the data structure. It includes one value of Sales per day.
Basically I created a dummy data in Excel by creating dates (from 1-1-2017 to 2-2-2021) and filling some random values (unif dist *5000) against these.
I added Week[date] to columns and year[date] to rows as in your screenshot. I added sum(value) on the text marks card.
Thereafter, I added table calculation --> Moving average --> edited it for previous 4 values , next 0 values, (check current value if you want to include current record), then check Null if there are not enough values. (your requirement). --> click compute using -Specific Dimensions change the order of fields below - drag Year above than week (table across then down will also create the same view)
You should be able to get a view as desired.
Regarding your query on number of days in the week, Tableau caters it automatically if you have chosen it datepart.
Edit I verified this in Excel, the method is correctly working.
See, the average of first 28 values in Excel
and the view built in tableau:
Here's the corrected dashboard hosted on Tableau Public.

Adding a Calculated Row in Tableau

I am displaying a table in Tableau for toys sales , I want to introduce a calculated row based on the previous row data. How can I do this in Tableau.
Toys type Sales in 2013 Sales in 2014
type1 10 15
type2 20 13
type3 30 28
type4 X/30 X/28
You can't specifically add one row to your database in Tableau. Calculated fields behave like fields, i.e. new columns.
If you explain what you're trying to achieve with this new row, we might be able to provide a solution. Adding a row, just for the sake of it, is not possible. You would need to manipulate your data source outside Tableau.
One thing you can do is create a calculated field to do that calculation for every row. Simple
X / [Toys type]
And X can be a number or a parameter

How can I sum up values by date(month) in report builder 3.0 graphs?

I'm trying to sum the data points by Months instead of individual days. The data is originating from an SQL Query so I'm thinking this may be the only way to do that. However, I would much rather do this inside of Report Builder 3.0. Any hints on how to do this?
For example, I want to see the number of tickets for the Months of December and January as only two seperate data points.
can you create a new field ( calculated perhaps) onthe dataset and group by that?
else you should be able to create an expression on the graph's group that groups by Month of a certain field.

Want to create 2 columns with different period parameters from the same data in SSRS

I want to create a monthly report, calculating the % from the previous 2 month average from the previous 12 months average. Basically I want to see which shops have dropped in sales in the previous 2 months, and hopefully only show the shops that have decreased 20% in sales.
So i believe the columns need to be like this
Shop|Products|Avg of 12 months|Avg of 2 months| %
Since i have many entries for the sales, i also need to sum the previous 12 months and then average it... as well as sum the previous 2 months and average it
I have thought of some ways to do it, but it didnt seem to work and seems all too complicated and complex.
Im hoping if there is a simpler solution to this? Do i need to use pivot table?
I'm using PostGres 9.1 on Visual Studio 10
Thanks a bunch
When something seems too complicated to resolve with a single query, I create and populate a DataTable runtime and pass it to ReportViewer.
In this case you can:
create a DataTable with Shop and Product as a PK (if you want print the report for a period of months you can also add Month as PK). The other 2 columns will be Avg12Months and Avg2Months
insert a record for each combination of Shop/Product (and eventually Month)
for each record Shop/Product calculate and save the results for Avg12Months and Avg2Months
pass your DataTable to ReportViewer
use a single Tablix to display the results (sort, grouping and other operations can be done in the Tablix)
Some passages can be combined in order to speed up the process.

Dynamically generating all dates in a month in Crystal Reports

I'd like to display dynamic columns at run time for each day in a given month.
Example:
If January then 31 columns will be displayed.
If February then 28 columns will be displayed.
If March then 31 columns will be displayed.
If April then 30 columns will be displayed. And so on.
How can I do this?
You have two challenges: creating the data and 'pivoting' it.
Most data warehouses contain a date-dimension table that you could query to get all of the dates for a given month and year. If you want something more dynamic, you might be able to adapt my DateRanges() function for this purpose.
The next challenge it to convert the rows to columns. Crystal Reports' cross-tab does this with ease, at the expense of some flexibility. I usually make use of the summarized-field's Display String formula to do fancy formatting.
You could also create 62 formula fields (31 for the labels and 31 for the data), place them on the canvas, and suppress the 29th - 31st fields as appropriate.
If this report is being generated by custom code (as opposed to being deployed in BusinessObjects Enterprise), you could use the Crystal Reports SDK to dynamically create the columns that you need.