Transform Excel Spreadsheet from one format to another - excel-2010

I have a list of data, that comes from a database that is exportable to excel. But the data comes out looking like this..
Room Name Model_Number Type
Name_A 3243234 Projector
Name_B 3233566 Projector
Name_C 1232322 Projector
Name_C 9299393 Camera
Name_A 9383888 Camera
Name_B 773984 Camera
Name_A 875649 Projector
Name_B 38292A3 Camera
What I need is the data to look like this
Room Name Projector1 Projector2 Camera1 Camera2
Name_A 3243234 875649 9383888
Name_B 3233566 773984 38292A3
Name_C 1232322 9299393
Does anyone know how to accomplish this.. I am thinking I am going to have to write some VB Code that takes each Type column, removes duplicates and then converts the rows into columns into a second spreadsheet then iterate through the Name find the value that matches from the first spread sheet if one exist and then populate the second. Just curious if i am on the write track. ( I haven't done any coding in VB or Excel other than the base stuff, but always willing to learn)

You can do this with a pivot table very easily - create a new pivot table, select Room_Name as the Row Labels, Type as the Column Labels and Model_Number as the Values.

Related

Bring back 10 lowest values based on a condition

I have a table measuring the distance and time via public transport between two postcodes. The postcodes are down column A and also are written in row 1:1 (photo below to explain)
I want to write a formula that says
Match Area name - ie 'Holborn' in the horizontal row, search down column matching 'distance' and return 10 smallest values telling me the distance BUT also bring back the matching store (from column A).
Help very much appreciated.enter image description here
I was trying to achieve it with a filter, sort and limit but I'm not getting anywhere.
try:
={A2:A, FILTER(B2:Z, B1:Z1="Holborn")}

To find XIRR for different investments using google sheet

I am currently trying to calculate the XIRR of a huge portfolio containing non-periodic cashflows. The database contains lot of transactions and I want to calculate the XIRR for each one.
This image contains the format and the last column contains the TICKER names of firms. I want to calculate the XIRR for these firms. The database on the left contains all the data for the ticker names
Please find the sample sheet here:
https://docs.google.com/spreadsheets/d/1LnTHOuw5FROyZ8tNo1Zl270RhTDX1gfB2m7jtEU9F_k/edit?usp=sharing
on your sheet you will find a new tab called MK.Help.
This is how you find XIRR for an investment like what you have:
=XIRR({FILTER(D:D*E:E,A:A=H5);-I5},{FILTER(B:B,A:A=H5);TODAY()})
The key is that you need to add the CURRENT HOLDING and todays date at the end of the arrays of cashflows. The idea is to imagine that you liquidated the position right NOW.

Extract Last Value as Metric from Table Calculation in Tableau?

I have raw data in Tableau that looks like:
Month,Total
2021-08,17
2021-09,34
2021-10,41
2021-11,26
2021-12,6
And by using the following calculation
RUNNING_SUM(
COUNTD(IF [Inserted At]>=[Parameters].[Start Date]
AND [Inserted At]<=[End Date]
THEN [Id] ELSE NULL END
))
/
LOOKUP(RUNNING_SUM(
COUNTD(IF [Inserted At]>=[Parameters].[Start Date]
AND [Inserted At]<=[End Date]
THEN [Id] ELSE NULL END
)),-1)*100-100
I get
Month,My_Calc
2021-08,NULL
2021-09,200
2021-10,80.4
2021-11,28.3
2021-12,5.1
And all I really want is 5.1 (last monthly value) as one big metric (% Month-Over-Month Growth).
How can I accomplish this?
I'm relatively new to Tableau and don't know how to use calculated fields in conjunction with the date groupings aspect to express I want to calculate month-over-month growth. I've tried the native year-over-year growth running total table calculation but that didn't end with the same result since I think my calculation method is different.
First a brief table calc intro, and then the answer at the end.
Most calculations in Tableau are actually performed by the data source (e.g. database server), and the results are then returned to Tableau (i.e. the client) for presentation. This separation of responsibilities allows high performance, even when facing very large data sets.
By contrast, table calculations operate on the table of query results that were returned from the server. They are executed late in the order of operations pipeline. That is why table calcs operate on aggregated data -- i.e. you have to ask for WINDOW_SUM(SUM([Sales)) and not WINDOW_SUM([Sales])
Table calcs give you an opportunity to make final passes of calculations over the query results returned from the data source before presentation to the user. You can for instance calculate a running total or make the visualization layout dynamically depend in part on the contents of the query results. This flexibility comes at a cost, the calculation is only one part of defining a table calc. You also have to specify how to apply the calculation to the table of summary results, known as partitioning and addressing. The Tableau on-line help has a useful definition of partitioning and addressing.
Essentially, table calcs are applied to blocks of summary data at a time, aka vectors or windows. Partitioning is how you tell Tableau how you wish to break up the summary query results into windows for purposes of applying your table calc. Addressing is how you specify the order in which you wish to traverse those partitions. Addressing is important for some table calcs, such as RUNNING_SUM, and unimportant for others, such as WINDOW_SUM.
Besides understanding partitioning and addressing very well, it is also helpful to learn about the functions INDEX(), SIZE(), FIRST(), LAST(), WINDOW_SUM(), LOOKUP() and (eventually) PREVIOUS_VALUE() to really understand table calcs. If you really understand them, you'll be able to implement all of these functions using just two of them as the fundamental ones.
Finally, to partially address your question:
You can use the boolean formula LAST() = 0 to tell if you are at the last value of your partition. If you use that formula as a filter, you can hide all the other values. You'll have to get partitioning and addressing specified correctly. You would essentially be fetching a batch of data from your server, using it in calculations on the client side, but only displaying part of it. This can be a bit brittle depending on which fields are on which shelves, but it can work.
Normally, it is more efficient to use a calculation that can be performed server-side, such as LOD calc, if that allows you to avoid fetching data only for client side calculations. But if the data is already fetched for another purpose, or if the calculation requires table calc features, such as the ability to depend on the order of the values, then table calcs are a good tool.
However you do it, the % month-to-month change from 2021.11 (a value of 26) to the value for 2021.12 (a value of 6) is not 5.1%.
It's (( 6 - 26 ) / 26) * 100 = -76.9 %
OK, starting from scratch, this works for me: ( I don't know how to get exactly the table format I want without using ShowMe and Flip, but it works. Anyone else? )
drag Date to rows, change it to combined Month(Date)
drag sales to column shelf
in showme select TEXT-TABLES
flip rows for columns using tool bar
that gets a table like the one you show above
Drag Sales to color (This is a trick to simply hold it for a minute ),
click the down-arrow on the new SALES pill in the mark card,
select "Add a table calculation",
select Running Total, of SUM, compute using Table(down), but don't close this popup window yet.
click Add Secondary Calculation checkbox at the bottom
select Percent Different From
compute using table down
relative to Previous
Accept your work by closing the popup (x).
NOW, change the new pill in the mark card from color to text
you can see the 5.1% at the bottom. Almost done.
Reformat again by clicking table in ShowMe
and flipping axes.
click the sales column header and hide it
create a new calculated field
label 'rows-from-bottom'
formula = last()
close the popup
drag the new pill rows-from-bottom to the filters shelf
select range 0 to 0
close the popup.
Done.
For the next two weeks you can see the finished workbook here
https://public.tableau.com/app/profile/wade.schuette/viz/month-to-month/hiderows?publish=yes

Google Spreadsheet: Script to pick the right values from data which is html-imported and never in the right order

I have the following problem I can't solve:
There is data of a measuring station for water quality available online (https://hamburg.de/clp/hu/fischerhof/clp1/). It updates every day, but the data is nowhere stored or put into a chart. So my play was to have a script which imports the data automatically. Functions in my spreadsheet would do the rest and put e.g. the water temperature in a chart. So far so good, I found all the scripts and work arounds here.
Then I discovered a problem I can't solve: When the data is uploaded on the website, it is not in the same order. Sometimes water temperature is in the first row, sometimes in the last, sometimes anywhere between. This messes all my data up, as I use a function which filters e.g. every 12-th row, to filter all the water temperature values out and make a chart out of it. When that position changed because of the import, I get wrong values.
Here is my setup so far:
I import the data into Sheet 1 with a script
This script also gathers the data in Sheet 2, where I filter the Water temp values on the right side, the red value shows the problem I mentioned aboth
Have you guys an idea how I can solve this problem? It's my first "project" of this kind, it was really fun until I discovered the problem, but I would really love to make it work!
Use this query
=QUERY(A2:C40,"select A, C where B matches 'Wassertemperatur'
label A 'date', C 'Watertemp.'",1)

Trying to create an SPSS Modeler Stream to calculate minimum distance between many geographic lat-long points and Points of Interest

I have a list of hundreds of thousand of addresses with their Latitude/Longitude data.
In a second table, I have the Latitude/Longitude of hundreds of gas stations.
I need to derive a table with the lat/long of the house, the distance to THE CLOSEST gas station, and the name of the gas station.
I'm trying to create a stream for SPSS Modeler (I'm using version 18.2).
In excel was fairly simple (see example below). In sheet one are the houses with lat/long, in sheet two the gas stations data, in sheet three how I did it in excel for a limited number of points, and in sheet four the resulting table. Basically, in excel I took the lat/long of each house and calculated the distance to all the gas stations and kept the smallest one.
I'll appreciate any directions or ideas on how to generate an SPSS Modeler stream to do something similar.
You can download my excel sample here: https://github.com/schapsis/calculating-distance-question
Please see the solution posted at https://developer.ibm.com/answers/questions/512605/how-to-calculate-distance-between-many-geographic/

Resources