Find the previous 3 month average value in Spotfire - spotfire

I am attempting to get the last 3 months average of out%. so far could not find any sample that suit for my requirement. Appreciate any help that could be provided.
There's a multiple column that i need to consider. I have to add the current month good% and the out% in the calculation to get the forecast.
This code gives me an error and the values reflected in the column is incorrect.
Sum([out]) / Sum([in]) over (LastPeriods(3,[month]))
Dt TotalIN TotalOut Good OUT% Good%
2/1/2019 79606 51384 0 64.55% 0
3/1/2019 84194 61211 0 72.70% 0
4/1/2019 92458 67807 0 73.34% 0
5/1/2019 94531 66988 95 70.86% 0.10%
6/1/2019 29623 18181 2903 60.94% 9.73%

Thanks for adding some data I could copy in. Below is the early morning hack I made a column of the summary table. I also binned the row axes to make this work.
Column Calculation:
(Sum([Good%]) * ((
Sum([TotalOut]) OVER (Previous([Axis.Rows],3)) + Sum([TotalOut]) OVER (Previous([Axis.Rows],2)) + Sum([TotalOut]) OVER (Previous([Axis.Rows],1)))
/ (
Sum([TotalIn]) OVER (Previous([Axis.Rows],3)) + Sum([TotalIn]) OVER (Previous([Axis.Rows],2)) + Sum([TotalIn]) OVER (Previous([Axis.Rows],1)))))
+ Sum([Out%])
Row Axes:
<BinByDateTime([Dt],"Year.Month",1)>
There might be a cleaner version with below but I'm not good with THEN. The problem with LastPeriods is that you want NULL if there aren't enough months.
THEN If(Count() OVER (LastPeriods(3,[Axis.X]))=3,[Value],NULL)

Related

count the total counts of cell per days

I am trying to find out the total number of order made in a day.
My data is like this :-
Date | Time | Product | Unit Sold
7/24/2018 10:45:59 Fries 1
7/24/2018 16:45:59 Fries 1
7/25/2018 12:45:59 Fries 1
7/25/2018 11:45:59 Fries 1
7/25/2018 1:45:59 Fries 1
7/25/2018 1:45:59 Fries 1
Now here you can see the count of 7/24/2018 is 2 , 7/25/2018 is 4 ..
I can manually filter and select all column and just copy the count from bottom bar.
but the problem is I have calculate of about 3 months of about 10 different branches.
I did googled up and found out about COUNTIF . and here what I tried
=COUNTIFS(range,">="&date1,range,"<="&date2)
But it returns me #N/A
Can anyone help me on here?
What you are asking is very simple, and can done with a little focus.
Step 1: Make sure the dates in date column are in the same format as with your system date. If yes then move to step 2, if not, Select date column -> then goto Data tab in Excel ribbon -> Under data tools you will find Text to columns -> Click that and convert the Dates to your system date format. move to Step 2
Step 2:
The formuala you mentioned
=COUNTIFS(range,">="&date1,range,"<="&date2)
I am assuming is an example and real code should look something like this unless you are using Names for ranges
=COUNTIFS(A2:A7,">="&B9,A2:A7,"<="&B10)
OR a better version would be
=SUMIFS(D2:D7,A2:A7,">="&B9,A2:A7,"<="&B10)
since this formula will actually sum up the Unit Sold column instead of date column. Example attached in image below. Enjoy.
sumif and countif example image

SUMIF formula to find sum for dates today or earlier

so I have this table of salaries that I make (hypothetically):
A B C D
1 Date salary how_much_I_earned_so_far
2 total =SUM(salaries_until_today)
3 2017-10-1 5000
4 2017-11-1 5000
5 today-> 2017-12-1 5000
6 2018-01-1 5000
7 2018-02-1 5000
8 future.. 2018-03-1 5000
9 2018-04-1 5000
now I want to calculate on D2 the amount of money I have earned so far..
to do that, I want to sum up all the past salaries from C3 all the way down to C_x where x is the index of the line where today < B_x
so that raised me two questions
1) how do I select unknown index of cell? usually when I do formulas it looks like this =SUM(C2:C9) so how can I make the number 9 be variable?
2) can I create variable that depends on a number of lines of where a cell is smaller than a value? I know how to get the current day, its simply =TODAY() but now I want to compare it with all B's and find the index of line where its smaller than it.. how do I start?
I'm sorry if that's a weird question, I'm a programmer and its frustrating me that a simple thing that I could quickly solve by code cannot be accomplished in a sophisticated app such excel..
thanks.
=SUMIF(B:B,"<=" & TODAY(),C:C)

EXCEL Count number of weeks in month based on date

I am trying to look up a value in a matrix based on a given date. The matrix has the first day of the week along the vertical axis, and the first day of the month along the horizontal axis.
For a given day, e.g. 31/08/15 I would like to match the exact date to the vertical axis of the matrix (i.e. 31/08/15), and the month to the horizontal axis (1/08/15).
So in the example below, an input of 31/08/15 should provide an output of 3.
01/06/2015 01/07/2015 01/08/2015 01/09/2015
03/08/2015 1 0 0 0
10/08/2015 0 2 0 0
17/08/2015 0 0 3 0
24/08/2015 0 0 0 4
31/08/2015 0 0 3 0
I am trying and failing with index and match formulae.
I have tried the following:
=index(area where to look, match(31/08/15,first column,0),match(and(month(31/08/15),year(31/08/15)),(and(month(first row),year(first row)),0)
Hope this is clear, thanks!
You can use an INDEX function with two MATCH functions top supply both the row and column.
    
The formula in D8 is,
=INDEX($B$2:$E$6,MATCH(C8,$A$2:$A$6,0),MATCH(DATE(YEAR(C8),MONTH(C8),1),$B$1:$E$1,0))
I'm a little concerned about the dates matching exactly down column A but a little maths manipulation with the WEEKDAY function would take care of that.
=INDEX($B$2:$E$6,MATCH(C9-WEEKDAY(C9, 2)+1,$A$2:$A$6,0),MATCH(DATE(YEAR(C9),MONTH(C9),1),$B$1:$E$1,0))
Here you go:
=INDEX($B$2:$E$6,MATCH(DATE(2015,8,31),$A$2:$A$6,),MATCH(DATE(2015,8,1),$B$1:$E$1,))

how to count of issue with open status in spotfire

I need to calculate count of issue ID for each month with open status.
I have below 3 columns-
Issue_ID
Issue_Open_Date
Issue_Closed_Date
Issue_ID Issue_Open_Date Issue_Closed_Date Open_Issue_Count(required output)
IS_10 11/11/2014 1/5/2015 3
IS_11 11/12/2014 12/14/2014
IS_12 11/13/2014 11/15/2014
IS_13 11/14/2014 3/5/2015
IS_1 12/1/2014 12/15/2014 4
IS_2 12/2/2014 2/10/2015
IS_3 12/3/2014 1/15/2015
IS_4 1/1/2015 2/10/2015 4
IS_5 1/2/2015 3/11/2015
IS_6 1/3/2015 1/22/2015
IS_7 2/1/2015 3/5/2015 3
IS_8 2/2/2015 2/2/2015
IS_9 2/7/2015 2/28/2015
IS_14 3/1/2015 4/5/2015 1
Based on above table, i need a count of open status of each month.
lets suppose in December i need to count than it should check in dec and nov month.
If any issue is closing in same month, it mean that is not in open stage,
Basically for each month it should check for their records also and previous month records also.
Required output is below-
Nov- 3
Dec- 4
Jan-4
Feb-3
march-1
So... I have a way but it's ugly. I'm sure there's a better way but I spent a while banging my head on this trying to make it work just within Spotfire without resorting to a python script looping through rows and making comparisons.
With nested aggregated case statements in a Cross Table I made it work. It's a pain in the butt because it's pretty manual (have to add each month) but it will look for things that have a close date after the month given and an open date that month or earlier.
<
Sum(Case
when ([Issue_Closed_Date]>Date(2014,11,30)) AND ([Issue_Open_Date]<Date(2014,12,1)) then 1 else 0 end) as [NOV14_OPEN] NEST
Sum(Case
when ([Issue_Closed_Date]>Date(2014,12,31)) AND ([Issue_Open_Date]<Date(2015,1,1)) then 1 else 0 end) as [DEC14_OPEN] NEST
Sum(Case
when ([Issue_Closed_Date]>Date(2015,1,31)) AND ([Issue_Open_Date]<Date(2015,2,1)) then 1 else 0 end) as [JAN15_OPEN] NEST
Sum(Case
when ([Issue_Closed_Date]>Date(2015,2,28)) AND ([Issue_Open_Date]<Date(2015,3,1)) then 1 else 0 end) as [FEB15_OPEN] NEST
Sum(Case
when ([Issue_Closed_Date]>Date(2015,3,31)) AND ([Issue_Open_Date]<Date(2015,4,1)) then 1 else 0 end) as [MAR15_OPEN]>
Screenshot:
As far as doing it with python you could probably loop through the data and do the comparisons and save it as a data table. If I'm feeling ambitious this weekend I might give it a try out of personal curiosity. I'll post here if so.
I think what makes this difficult is that it's not very logical to add a column showing number of issues open at a point in time because the data doesn't show time; it's "one row per unique issue."
I don't know what your end result should be, but you might be better off unpivoting the table.
unpivot the above data with the following settings:
pass through: [Issue_ID]
transform: [Issue_Open_Date], [Issue_Closed_Date]
optionally rename Category as "Action" and Value as "Action Date"
now that each row represents one action, create a calculated column assigning a numeric value to the action with the following formula.
CASE [Action]
WHEN "Issue_Open_Date" THEN 1
WHEN "Issue_Closed_Date" THEN -1
END
create a bar chart with [Action Date] along the X axis (I wouldn't drill further than month or week) and the following on the Y axis:
Sum([Action Numeric]) over (AllPrevious([Axis.X]))
you'll wind up with something like this:
you can then do all sorts of fancy things with this data, such as show a line chart with the rate at which cases open and close (you can even plot this on a combination chart with the pictured example).

Is there a way to make Lookup always return the first encountered match in a column?

I have user retention data that looks like this:
signup_date days retention
2/24/13 0 1
2/23/13 0 1
2/23/13 1 0.4855
2/22/13 0 1
2/22/13 1 0.4727
2/22/13 2 0.3647
2/21/13 0 1
2/21/13 1 0.5135
2/21/13 2 0.3879
2/21/13 3 0.3463
2/20/13 0 1
2/20/13 1 0.5402
2/20/13 2 0.4166
2/20/13 3 0.3615
2/20/13 4 0.3203
2/19/13 0 1
2/19/13 1 0.5317
2/19/13 2 0.4348
2/19/13 3 0.366
2/19/13 4 0.3077
The second column ("days") represents days elapsed since the signup date and the retention is based on that day and the signup_date (since retention can change over time). I need to make projections going forward, and unfortunately for me (since I would prefer to do this programmatically), my boss wants them in Excel. So I'm trying to use the Lookup() function to find the most recent value in the retention column that would match the "days" elapsed from a certain signup date.
Anyway, that's all prelude to the question, which is that right now if I enter the formula:
=lookup(1,B:B,C:C)
where B:B is "days" and C:C is retention, it doesn't necessarily return the first (i.e. most recent) retention value in the data set. For example, in this case, I need the cell to be 0.4855, but the formula may give me 0.4727 (which is the second "days=1" row). Is there any way to configure it to do this or is there another function that will do what I need?
Instead of using LOOKUP, use the VLOOKUP function - it has another parameter that specifies that the data is not in order:
=VLOOKUP(1,$B:$C,2,0)
This will return you the entry in the second column of your range B:B where "1" is found in the first column of your range. Do not forget the 0 at the end, as this tells Excel to search row by row (vs. a binary search as LOOKUPor omitting the parameter would do).
Alternative:
VLOOKUPis the simple formula and default for those situation. The even better, as more flexible way is to use INDEX/MATCH:
=INDEX($C:$C,MATCH(1,$B:$B,0))
This will do exactly the same, just that you have a bit more flexibility and don't need to include the "second column from the lookup data"...
HTH!

Resources