(SpotFire) Aggregated Average - spotfire

I have a challenge.
See example data below.
ID Prod Weight Mnd Year
1 XXX 2344 Jun 2018
2 XXX 2344 Jun 2018
3 ZZZ 3344 Jun 2018
4 ZZZ 3344 Jun 2018
5 ZZZ 3344 Jun 2018
6 ZZZ 3344 Jun 2018
I'm looking for a calculated column to show the average per month/year.
Problem is: amount of rows differs for the products. If I do an AVERAGE then the Product with the most rows has a bigger influence on the outcome then it should. In above example "AVERAGE([Weight]) over ([Month],[Year])" doesn't work. In this example the outcome of the formule is 3011 (wrong) iso 2844 (correct).
Any tips how to solve this.

You can solve this by adding a pivot table. File > Add Data Tables > Add > Choose your table. You may want to rename the new table by appending "_pivot" to the table name. Then in the transformations part of the window, choose Pivot from the drop down and then click the "Add..." button. For row identifiers, choose Prod, Weight, Mnd and Year. Note that I have omitted the ID column. Click OK. Then choose "Calculate new column" in the transformations drop down. You can now add your calculated column. Once you do, hit OK until the Add Data Tables window closes.

Related

Excel Plotting two Date Ranges on the same Pivot Table

I am trying to trend the occurrence of a system event in Excel. I've attached a screen shot showing the pretty simple data that I'm working with.
The spreadsheet lists the times of the event (Column A) for a two week period and I've used a ceiling formula to group those events into 15 minute increments (Column B). Using a pivot table and chart, it's pretty simple to then take that data and graph the events into a line chart that shows the 15 minute increment time, and the count of the events in that 15 minute period.
Now I'd like to take subsets of that data and compare them. For example I'd like to compare Friday Saturday Sunday of last week Friday Saturday and Sunday of this week. So far, the only way I found to achieve this is to create duplicate pivot tables (Columns E, F and H,I), filter each table by the days I want to compare (25, 26, and 27 in one table and 1, 2 and 3 in the second), and then visually compare them (the Two charts).
But what I'd really like to do is to combine both series into one chart as a stacked line graph. I thought that would be pretty simple, but since the dates are so very dissimilar, I always wind up getting a single line or duplicate data, or totally off the wall results.
I've gotten kinda close by converting the row labels in to a custom DDD HH:MM format. That lists the Dates as (For Oct 25th)
Fri 00:15 11
Fri 00:30 1
Fri 00:45 4
Fri 01:00 3
Fri 01:15 6
Etc.
And (For Nov 1st)
Fri 00:15 7
Fri 00:30 1
Fri 00:45 2
Fri 01:00 1
Fri 01:30 2
Etc
Now I have something I can join on (Friday 00:15, 00:30, 00:45, etc is in both charts)
But the problem is, the two series often don't have the same Labels. For example the data for Nov 1 is missing 01:15,01:45 and 02:00 because no events occurred at those times. Same problem for the Oct 25th's data which is also missing 02:00 in addition to all increments between 02:30 and 03:45.
I tried just manually inserting the missing times in both charts but that quickly became a very complex and error prone chore.
So the question is: Is there a way to get excel to automatically fill in the missing time slots or am I completely off base in the way I'm trying to do this?
OK.. that was two questions :)
Thanks so much for your help!

How to count running months of a specific year?

I'm currently struggling with calculating the running months depending on the year. I have the following table:
Received Month Received Year
Feb 2018
Feb 2018
Mar 2018
... ...
Nov 2018
Nov 2018
Dec 2018
Dec 2018
Jan 2019
Jan 2019
Feb 2019
I was using this formula to count the # of unique months (running months in 1 single cell [C1]);
=SUMPRODUCT(1/(COUNTIF(KAIZEN_Table[Received Month],KAIZEN_Table[Received Month])))
This was working great in 2018, it gave me 11 (Feb - Dec).
I have to add a filter that also checks if the year is 2019. I can't remove 2018 in the table because the operators are still using the 2018 lines. The filter is just here to set a KPI for 2019.
For some reason I can't figure out how to add the year. I tried;
=SUMPRODUCT(1/(COUNTIFS(KAIZEN_Table[Received Month],KAIZEN_Table[Received Month],KAIZEN_Table[Received Year], "2019")))
This is just giving me a 0.
Any suggestions on this? VBA code is also fine.
Edit: After extensive googling I found a working formula, for whoever might be interested in this.
=SUM(IF(FREQUENCY(IF(tbl[Year]=2019,MATCH(tbl[Month],tbl[Month],0)),ROW(tbl[Month])-ROW($L$5)+1),1))
L5 = First row of tbl[Month]
I have my data in A1:B14, the formula I've used is an array one
=SUM(1/(COUNTIFS($A$1:$A$14,$A$1:$A$14,$B$1:$B$14,$B$1:$B$14)))
however,
=SUMPRODUCT(1/(COUNTIFS($A$1:$A$14,$A$1:$A$14,$B$1:$B$14,$B$1:$B$14)))
would suffice
To do a particular year, you could do something like this
=SUM(($B$1:$B$14=2019)*(1/COUNTIFS($A$1:$A$14,$A$1:$A$14,$B$1:$B$14,B1:B14)))
Another approach is to use a Pivot Table.
On the Create Pivot Table dialog, select to Add this data to the Data Model
If you do this, you will note that one of the options in the Value Field Settings will be Distinct Count
Drag Received Year to the Rows Column; Received Month to the Values column, and select Distinct Count for the Value Field Setting

Finding MTD, QTD, and YTD in excel from monthly returns

I've been working on this for awhile and can't seem to find an appropriate way to code this.
Goal: Take a list of monthly returns that currently spans over three years (this is an automated list so it will keep adding months) and find MTD, QTD, & YTD using function so I can automate the process.
Problem: I've tried the OFFSET function, different versions of COUNT, IF statements and can't find a way to properly code the function.
NOTE: this is for stock data/earnings report
Just to clarify, I know how to do this manually, but want to automate the process :) Would be more than happy to use VBA but would like to stick to a simple function if possible...
I'd be more than happy to email the WS to someone. Thanks so much!!
If you want to keep it simple and avoid vba here is a suggestion
The manner in which the data sheet is presented matters.
I assume months go down, with there only being 1 column for 'monthly returns'?
On a separate area/worksheet, set up the months with a value for what they are in the column next to them. Ie
Jan 1
Feb 2
Mar 3
Apr 4
...
Dec 12
then have a drop down where you can select what month it is.
so if it is Jul, you can select Jul.
From here, do a vlookup/indexmatch to pull the number for the month through, so Jul would be 7
From here the MTD is easy.
Do an offset from the beginning of the year to the current month
=offset ([start point],[month number],[columns])
=OFFSET($D$1,$C$21,0)
start point will be one row above Jan, that way when Jan is chosen it will fall onto Jan.
Month number you will get from what was said earlier
and columns will depend on how you place it
YTD, you will do the same as above but have a sum
so
=sum(B3:offset ([start point],[month number],[columns]))
=SUM(D2:OFFSET($D$1,C21,0))
QTD would be easiest just plotting the sums as it would never change
So set out Q1,Q2,Q3 and Q4 as prefixed ones. Then lookup to them.
However, if you want to see the most recent quarter by a formula. On the month number list add a new column which says what quarter it is. Then
Jan 1 1
Feb 2 1
Mar 3 1
Apr 4 2
...
Dec 12 4
It should the read off a formula like so
=SUM(
OFFSET([start point],(INDEX([month number table],MATCH([month],[month list],0),3)-1)*3,0):
OFFSET([start point],INDEX(month number table],MATCH([month],[month list],0),2),0))
=SUM(
OFFSET($D$2,(INDEX($F$2:$H$13,MATCH($C$20,$F$2:$F$13,0),3)-1)*3,0):
OFFSET($D$1,INDEX($F$2:$H$13,MATCH($C$20,$F$2:$F$13,0),2),0)
)
What you are doing is to find the month at the beginning of the quarter and then sum to the current month.
Regarding this bit at the end
OFFSET([start point],(INDEX([month number table],MATCH([month],[month list],0),3)-1)*3,0):
You are finding the month quarter index number(1,2,3,4) and multiplying it by three. The reason you want to take away one before multiplying by three is because you want the start point of the quarter, thus in jan to march, this will be 0, and then you add a row to get the start point being Jan.
In Oct to Dec this will be (4-1) = 3. 3x3 = 9 which will be Oct to make Oct being the start point. Amend as need be.
The yellow section is what your actual information is presented as
The green section is your lookup area
The Blue area is information you are looking for with the lower bit reading from the lookup

Adding YTD, YTG column to Excel OLAP Pivot

I have an Excel pivot table connecting to an OLAP cube with a report looking something like
Jan Feb Mar .........Dec
Revenue 55 32 65..........45
I'd like to add extra columns YTD and YTG etc. These are already calculated measures in my cube, but when they are added to the Pivot table, not surprisingly, the months are repeated for each measure.
I just need the columns at the end like
Jan Feb Mar .........Dec YTD YTG
Revenue 55 32 65..........45 654 30
Is this possible?
I've got a solution although an inelegant one. Basically to create calculated members for Jan-Dec and uses these as columns in the report.
As I say, inelegant but client likes it.

Excel Sum Similar Rows via Macros

I found an answer similar to my question on these boards. However, my data is setup differently and I wasn't getting the results I needed.
My data in Excel looks like the following:
ParcelNumber BillNumber OwnerName Code Year DollarAmount
111222 9117222 Smith, Bill 22 2013 $999
111222 9117222 Smith, Bill 22 2013 $276
111222 9117222 Smith, Bill 22 2013 $100
111223 9110001 Tan, Steve 22 2013 $96
111223 9110001 Tan, Steve 22 2013 $12
111224 9112396 Bishop, John 22 2013 $126
111225 9113333 Fidel, Jason 22 2013 $990
I need to do the following:
For all of the Parcel numbers that are the same, total up the Dollar amount and consolidate one one line per parcel number. The output would look like this:
ParcelNumber BillNumber OwnerName Code Year DollarAmount
111222 9117222 Smith, Bill 20 2013 $1375
111223 9110001 Tan, Steve 20 2013 $108
111224 9112396 Bishop, John 20 2013 $126
111225 9113333 Fidel, Jason 20 2013 $990
Thank you very much.
Warning: Quite a lot of images coming...
Okay, select your entire table and go to Insert > PivotTable and click OK in the wizard.
Click, drag and drop all the fields but the last one from the right pane to the box in the lower left. The last field goes in the box in the lower right. You should get something like this:
Go to PivotTable Design and in Layout, pick Show in Tabular Form and Do not show subtotals.
And you should be done! You can copy the information you need to another sheet as required.
If the amounts aren't displaying properly, make sure that the calculation is "Sum" and not "Count". You get "Count" as default if there is a non-numeric cell in the column you are pivoting. To change the calculation, simply right click on any number in the pivot table, go to 'Summarize data by' and check 'Sum'.

Resources