I have a large dataset, about 3600 rows, that contain product data. Each one is a different line item with different $ values associated with it. I am trying to consolidate this dataset into one row per unique account with all of the pricing data and products rolled up into one row.
What would be the best way using Excel or SQL or Microsoft Power BI to transform the first table into the desired table??? I can sort of do what I am thinking of by using a pivot table but it doesn't turn into a single row, though it does summarize like this.
Starting Table
Desired Table
Thanks!
You could achieve it by Power Pivot:
Where Product by Customer is a Measure created by the formula:
=CONCATENATEX(Table2,[Product],"; ")
For larger dataset this seems to work better:
=CALCULATE(CONCATENATEX(VALUES(Table2[Product]),Table2[Product],"; "))
To create the Measure:
Click on your pivot table and got to "Power Pivot", upper right corner. Then click "Measures" -> "Manage Measures..."
Click "New" and fill in with the formula.
Notice I have ";" as delimiter but you might have ",".
Related
I'm currently working on an Inventory Control db that allows tracking stock transactions from one location to another but, I can't figure out how to create 2 records simultaneously on a "Transactions" Table based on the same data.
Basically, I'd like to create a form where I enter Item, Qty, From Location, To Location, Lot and have 2 records created simultaneously with a negative qty on the "From Location Record" and a Positive Qty on the "To Location Record".
I've attached a screenshot of the Form I envision and the desired Output in Data Records.
I have some experience working with Access forms and tables but this development is beyond my knowledge.
I Hope someone can help.
Thanks!
Form & Table screenshot
You would run couple of simple insert queries. One to move the stock out from the existing location, one to add it back to the new location.
If you are not well versed with writing VBA I would use the query designer, and include your form text boxes as the criteria. Save the queries, then use your button to run the queries one after the other.
I would also be tempted to bring in the existing location as a combo box based on the part number selected. That way you won't try and move something from a location that isn't correct,
I have a question about the "Data Model" in excel. Whenever I read about this function, it is used with PowerPivot.
I ask because I would like to do something like this:
I have table A:
ID
info1
And table B:
ID
info2
Now if I connect these tables with with the data model function (through the ID-Column), I thought that I could then join tableB.info2 to tableA and have a table that shows ID,info1,info2
But that doesn't seem to be possible, or is it possible and I'm doing something wrong?
Is there ANYTHING you can do with datamodels without using PowerPivot? I feel like I'm missing the point of this feature.
Since Excel 2013 onwards, the DataModel CAN be used without PowerPivot. You can load tables (or other data sources) into it, and you can even add measures using DAX (although you can't add Calculated Columns). Check out the following links for examples:
https://youtu.be/FVVK-8QZC1M (Mike Girvin shows you how to use DAX without PowerPivot to create measures for PivotTables based on the Data Model)
https://blog.crossjoin.co.uk/2012/07/16/what-are-the-big-changes-in-excel-2013-for-bi/ (Read the comments to understand how the DataModel has been made completely separate from PowerPivot. In effect, PowerPivot is just a UI that lets you do things to the DataModel)
https://powerpivotpro.com/2014/07/adding-tables-to-a-model-from-vba-in-excel-2013/ (Dany explains how you can do stuff to the DataModel using VBA)
http://dailydoseofexcel.com/archives/2017/07/10/look-ma-no-powerpivot/ (My post, covering the above)
PowerPivot is a highly advanced tool that takes the hassle out of tables. It saves you a whole lot of time.
The "Data Model" is at the "core" of PowerPivot, PivotTables, and PowerView, and cannot be used apart from either of these three tools.
What you're talking about can be achieved, but is best handled in a VLOOKUP or INDEX(MATCH()),
But let's just say we want to go down that route, because honestly I do sometimes.
First,
Hook up your ID values in your data model between table 1 and table 2, the arrow flowing towards table 1 that only has info1.
Create a calculated column in table1, give it the formula
=RELATED(table2[info2])
Name that new column you just added "related info2"
And your value populates magically.
But how do you get it back into your excel workbook? It's not at all a "clean" solution, which is why we recommend VLOOKUP or MATCH(INDEX())
What you'll want to do to bring your info2 into your excel sheet is use a "Flattened PivotTable".
You can create this type of PivotTable in your PowerPivot Editor, by pressing the "PivotTable" button.
Put your Flattened PivotTable right beside the other table in your Excel worksheet that you want info2 at, like you're magically going to populate the info2 column right beside it, because you're about to.
Drag and drop all PivotTable fields from the table that contains our calculated column to the "rows" box, including that "related info2" column we just created in table1.
To get the right values on the right rows, go into your Design tab, and click on the "Subtotals" button, disable all subtotal, and do the same with the "Grand Totals" button, disable all grand totals.
Make sure your "Report Layout" is "Compact", also found in the Design tab.
Optional: You can add a field to "values" to allow row formatting to recognize the rows, otherwise the PivotTable thinks that there are no rows and you won't get anything but a mostly solid color, no matter how many designs you try to switch to (we're doing something tricky, remember?)
Now hide all the columns in your excel sheet you just created with the PivotTable except your "related info2" column.
So yes, it is possible to do, but you're better off with a VLOOKUP or INDEX(MATCH())
Hi I am new to SSRS and I created a form. I also added a couple of column based on expressions. I was trying to sort the table on the basis of an expression column but the option is not available in cell properties - interactive sorting. Can anyone please guide me on how to achieve it. Thanks.
You have two ways of solving this that I can think of. You can either:
Move your calculated columns to your Dataset
When you add a dataset to a report, on the Fields tab you have the option to add Calculated Fields. If you add your expression column here, you will be able to use it in the Sort tab of your Tablix just as you would a normal column.
OR
Repeat the expression in the Sort property.
If you are not able to create your calculated field on your dataset (perhaps if you reference other datasets or do something out of scope), then you will need to duplicate your expression in the Sort tab of your Tablix. (To access this, click anywhere on your table and then right-click on the small grey square in the top left-hand corner of your table).
If you click Add for a new Sort condition and hit the fx button, you can paste the same expression you used for your column into here and use it to sort your dataset.
The downside of this is that you're replicating your logic and potentially duplicating work.
To enable the interactive shorting in a table you need to have a row group. So by this you can sort the whole table or only a portion of the table.
Say in your case you need to sort the table basis of some expression. For an example you need have an interactive sort based on the values. In the below screenshot I have 2 groups i.e. Customer and Project and I want to have an interactive sort based on the revenue.
Now right click on the Revenue and go to the 'Textbox' properties and select the group and sort by. Here in the screenshot I will sorting based on the total revenue for different Customers.
Now after running the report if you click on the Revenue column it will sort accordingly.
Let me know if this is what you are looking for.
I have a series of tables in an Access 2007 database. I am trying to find a way of outputting a flat-file to an excel spreadsheet that combines all of the tables so that each row of the flatfile represents a unique combination of the table rows from each table.
For example, these tables:
Would combine to make this output table:
The challenges I'm facing are:
The 'input' tables can vary in number of rows and columns, as well as quantity
The total number of rows in the final output table can get quite large (200,000+ rows)
I know Excel and VBA (in Excel) well but almost nothing about Access
Is there a way to do this in Access? Is there some native functionality in Access that I'm completely overlooking? Any pointers (even if it's "you need to read into X and Y") would be greatly appreciated!
Thanks,
Adam
As noted above:
Create a new query. Select your 3 tables as the data sources. If desired, set up joins between tables by dragging a line between a field in one table to a field in another. Without joins you will get a Cartesian Product ... every from 1st table paired with every row of 2nd table, and then each of those combination paired with every row of 3rd table. Select the fields you want included in the result set. When the query returns what you need, save it and give it a name. Then you can export that named query to Excel.
If the table is large, you could hit Excel's row / column limit though.
I work with a product that comes in a 2000lb sack and placed on a pallet. When this product is made it has many different elements that are tested and each test has a field that the numerical data is placed in. Each of these records of tests are then assign a number, for example, L20444.
Now we have the ability to take that 2000lb sack and convert it into 80 20lb bags. Only 40 20lb bags can fit on one pallet, taking now the one pallet L20444 and making two pallets that have the number L20444. This causes a problem with inventory because the number L20444 can only be assign one warehouse location, not two.
So my bosses what to create a number that is almost the same, but different enough to place the second pallet in the warehouse. The second pallet will now be L20444B. It will still have all the same tested numbers and is a "copy" of the original L20444.
My question is can I take the record L20444 and copy all the data for that record and then save it as L20444B so that it can be placed in the warehouse.
So is it possible for VBA to copy a record, rename it, and then save it in the same database as a new record?
Any help would be appreciated, Thanks.
If I'm reading you right it sounds like you want a SQL statement to create a new record.
You're using Microsoft Access? I would recommend first creating a query that does this in the query editor. It will be an Append query, something along the lines of:
INSERT INTO TableA ( ID,col1, col2 )
SELECT [ID] & "B" AS NewName,col1, col2
FROM TableA
WHERE (([ID]="L20444"));
Test this first to make sure it's doing what you want, and make "L20444" into a parameter ([OldID], or something). Then add some code in your VBA script that executes this query. It should pop up asking you for OldID when you run it.
Then you'll need to learn how to execute parameterized queries from VBA.
Something like this:
Set qdf1 = CurrentDb.QueryDefs("myQuery")
qdf1.Parameters("OldID") = theOldID
qdf1.Execute
Not tested, search VBA help for QueryDefs if my syntax isn't quite right.
Why don't you create a new table, which tracks the location of the two pallets (and the new number(s)), which links back (with a foreign key) to the single record for the stock in the original table?
That should work, and will avoid what will otherwise become a nightmare of redundant data.