Spotfire Bargraph to show Avg Quality by year for previous years and by month for current year - spotfire

I have a bargraph which shows the quality of my data for each month. As the data is growing over the years, the graph is getting messy. So, i would like to show Avg Quality by year for all those months in Previous years but monthly for the current year.
Can any one help me how to achieve this.
Thanks,
-Dileep

This needs to be separated into two charts, or it just won't be legible. I'd suggest:
Creating an AVG by Year bar chart graph for all your data
Creating a details visualization of the above Yearly Average data which shows the 12 months of that year with SUM() as your aggregation method. Be sure to have YEAR > Month on your category axis
Thus, if you need to compare 1, 2, 3 or all the years by month you can select them all, or just the ones you want.

I was able to do it with the help of some calculated columns. To help explain, let's assume the value column in your data set is called Value and the date column in your data set is called ValueDate. I created some fictional data that extends into April, 2017 to help illustrate the solution.
Insert a calculated column to classify whether or not the date in each row is in the current year or not. I'm going to call the column DateGrouping.
CASE WHEN Year(DateTimeNow())=Year([ValueDate]) THEN "Monthly" WHEN Year(DateTimeNow())>Year([ValueDate]) THEN "Yearly" END AS [DateGrouping]
Insert a calculated column that tells us the last date of the month for ValueDate. E.g., if the date in the row is 4/10/2015, the last day of the month for the day in that row is 4/30/2015. If the date in the row is 7/8/2013, the last day of the month for the date in that row is 7/31/2013. We'll call this column LastDateOfMonth.
DateAdd("day",-1,date(Year([ValueDate]),Month(DateAdd("month",1,[ValueDate])),1))
Insert a calculated column that tells us the last date of the year for ValueDate. Of course, it's just Dec. 31 of ValueDate's year. Call this column LastDateOfYear.
Date(Year([ValueDate]),12,31)
Finally, we utilize the previous three calculated columns to add a calculated column for the date value we want to plot. You are wanting to plot by month for the current year, and by year for prior years.
CASE [DateGrouping] WHEN "Monthly" THEN [LastDayOfMonth] WHEN "Yearly" THEN [LastDateOfYear] END
On my value axis is the Value column, which I'm aggregating as an Average. On my category axis is the calculated DatePlot column -- I set the category axis to Categorical Scale. And I'm coloring by the calculated DateGrouping column to offer a visual cue that the data is aggregated differently over time.
Now, should this be done? There are certainly some pitfalls. You can't make the category axis Continuous Scale or else you'll see all the empty months when we're lumping prior years into Dec. 31. On the other hand, gaps are good visually when there is no data for a given period. So I don't know. But I pictured what you were asking and decided to try it. Buyer beware!

Related

Calculating Monthly (Offset) Average In Excel

I have daily data entries for 3 indices. They do not feature every day of the month and for some days entries for one of the indices will miss; the quantity of cells per month differ. I want to calculate the average value for these individual indices starting the 16th of the prior month and going to the 15th of the current month (or the first date after the 15th/last day before the 16th if there is no entry). For example, in the screen grab below, the average for MXWO in the month of February would be the average of the array B14:B36 (and for January, B2:B13).
What my data looks like
I want to produce 4 columns: Date (Month-Year), average of MXWO, average of JPMIGHYS, and average of USTWBGD. Each of these averages needs to use the methodology described above. How might I achieve this?
I've tried using the OFFSET function, but since the cell increment changes month to month (there is a different amount of missing cells per month), this didn't work.

DAX for rolling seven day average to pivot chart by year

I'm trying to create a single pivot chart that will show separate years of data on the same date axis for a rolling 7-day average.
So, the x-axis will be text, 01-Jan to 31-Dec, and each year will be a separate series:
It has to be a text x-axis, as 01-Jan will be a category containing data for 01-Jan-2018, 01-Jan-2019, 01-Jan-2020...
In theory, the pivot table setup would have the column (series) as the Year, and the x-Axis (labels) as the date label (column Date).
The values are then from the DAX expression that creates the rolling 7-day average.
The source data (tblSource) has a single column of dates (Date2) that rolls over across years and has the column Year to break it down in the pivot.
The daily value is the one that is averaged (itself and the previous six days).
The 7-day average I normally use in DAX doesn't work here.
I need to have the Date column actually in the pivot rather than Date2, as the axis needs to be text to allow for multiple date years on the same x-axis point, but I can't get a DAX formula to work.
The other consideration is that the formula can't just consider a single year, as the rolling seven day average for 01-Jan-2018 includes the previous six days of 2017, for example.
This is the formula I usually use, but I can't manage to tweak it!
AVERAGEX (
DATESINPERIOD ( tblSource[Date2], LASTDATE ( tblSource[Date2] ), -7, DAY ),
[Sum of Daily Value]
)
But this is the output I get, and nothing has been averaged. I think it's because Date2 is being pivoted off Date, but I'm not sure how I get around that?
Can anybody offer me any help?
It's quite a frustrating problem as it would be trivial for me to do it using code, or doing it manually, but I really am trying to get better at DAX!
Thanks in advance!
Phil.
Update: Thanks to Joao for this.
=VAR d = MAX(tblSource[Date2])
RETURN CALCULATE(AVERAGE(tblSource[Daily Value]),
ALL(tblSource[Date]),
DATESINPERIOD(tblSource[Date2], d, -7, day),tblSource[Year]>0)
I had to use MAX rather than SELECTVALUE as Excel seems to lack that functionality.
I also had to unfilter the Year, so that the rolling average could be calculated from the previous year's date where neccessary.
Thanks.
When you run that measure, your table is being filtered by the date text at each point, so when you pass/create the DATESINPERIOD filter, it creates a table with the last 7 dates, but only one of them is actually available (the one relevant to your current data point).
You need to clear the filters on the table so that you have all the dates available, in order for you average to work. You can achieve this by changing the measure slightly:
VAR d = SELECTEDVALUE(tblSource[Date2])
RETURN CALCULATE(AVERAGE(tblSource[Daily Value]),
ALL(tblSource[Date]),
DATESINPERIOD(tblSource[Date2], d, -7, day))

How to count entries on monthly basis? Such that same row/entry can be counted in multiple months if conditions are met

I am trying to make a bar chart with X- axis showing timeline with respect to months (Jan, Feb, March etc). On Y-axis, I want to count how many [KRI] are there in each month based on their [Status Category]?
I have two conditions though:
1) If [Status Category] is 'Final', count that KRI in all months between [TRIGGERDATE] month and [statchedate]. for example, same KRI should be counted in Jan, and Feb and March etc (from time it was open till the time/month it was closed).
2) If [Status Category] is NOT Final, count that KRI in all months between [TRIGGERDATE] month and today's month.
In the picture below with the data sample, the pink colored blocks shows when the KRI should NOT be counted in that particular month.
I am trying to write a custom expression using if statement, but I am not able to figure out how would spotfire know that a KRI should be counted between [Triggerdate] and [Statchedate]? Or for instance, between [Triggerdate] and [today]
I am also thinking about adding a calculated column that will determine if the KRI should be counted in how many months? (but this will be ongoing data, so I am afraid that my column would keep on expanding..)
Any suggestions would be very much appreciated :)

Time series mock data generation for 16 years of quarterly data in Excel or Matlab

I would like to generate a mock time series quarterly dataset from, say, 2000-2016 for a variable (quarterly credit growth) that averages around a certain value (say, 30%). Can anyone give a suggestion on how to do this in principle?
Edit: what I was implying were the actual data values for each time period, i.e. data with a certain mean and variance.
Found a solution with a code in Matlab, for anyone interested, see below in answers.
Excel approach:
You can make column A your date list. In A1, or A2 or more if you have header rows, you will have to seed your list by providing the first start date. Lets assume you put your seed date in A2. I would then go about adding 3 month to you start date using a formula, and copy down until you have hit your desired date. In order to add the 3 months I would use the following in A3.
=date(year(A2),Month(A2)+3,day(A1)
that will give you the first day of the month every 3 months. If you want the first day of the month every 3 months, set the day to 1 like so:
=date(year(A2),Month(A2)+3,day(A1)
And end of month could be calculated as:
=eomonth(date(year(A2),Month(A2)+3,day(A1)),0)
however I would prefer to do the end of month calculation based on the row you are in so I would do it more like:
=EOMONTH($A$2,(rows($A$2:A3)-1)*3)

grouping in an excel pivot table with different year end and quartiles

I have a pivot table with a lot of items currently grouped by date into quartiles and then months under that. My question is this, Our Financial year is not Jan to Jan so can I set up quartiles to reflect this? also our financial periods are not simply set months, they follow the months but are always full weeks around that. for example, P1 this year is 04/07/2015 - 07/08/2015. and Q1 would be 04/07/2015 - 02/09/2015.
Aside from manually grouping is there a way to set this up to happen automatically within Excel?
As stated by pnuts in the question's comments:
The most practical way may be to define the quarters (?) in your source data.
If you are at least using a Gregorian calendar, you may want to subtract an offset from your dates (i.e. # of days between 01-Jan-YYYY and DD-MMM-YYYY ... whereby the offset YYYY doesn't need to be the same as your date's YYYY). By this subtraction you get an "ordinal number" of the date within your business year.
[offset] =[FOY]-DATE(YEAR([FOY]),1,1)
So with your year starting on [FOY]=04-Jul-2015, you have an offset of of 184 days and a normalized date of
[date_normalized] = [current_date]-[offset]
So 04-Jul-2015 will be shrunk to 01-Jan-2015. Now the quarter easily calculates to
=CEILING(MONTH([date_normalized])/3,1)
... or =VALUE(MID("111222333444",MONTH([date_normalized]),1)) ... if you prefer
For your not-quite-months always being full weeks, I suggest to calculate a week number by
=MOD(CEILING(([date_normalized]+1)/7,1)-1,52)+1
to create a weekly reporting period 1 .. 52. With a further =CEILING(.../4,1) this can be converted to quasi-months having 4 weeks each.

Resources