Excel Data Model without using PowerPivot - mysql

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())

Related

Access combo box for DB mapping table 2-1 Table relation

I've run into a bit of a snag with a project I'm working on, and being new to Access I don't know if what I want to do is possible without VBA. I've looked around but all I can find are answers related to showing multiple columns, not controlling multiple fields in my DB.
To paint a picture I have a mapping system set up in my DB to help me distinguish the name and type of data is held in a table.
The setup is as follows:
-Data table is "LineItems" with an ID and the line data (think typical excel format)
-Mapping table is "LineItem_Mapper" with LineItem_ID, DataType, and Entity_ID
-A helper table "Data_Type" with ID and Name
-two "Entity" tables with differing properties both have ID and Name
The reason for the split is on data type is that the two types of data behave differently. One type has a parent child relation, and the other is a standalone row. I want to preserve this structure in my DB and feel I have done so with this mapping.
Now, on to the issue I'm running into. In my Access data entry form I want to use a combo box, as the options a user may chose for each line when entering are finite. However, this combo box is affecting the Mapping table above. I have been able to populate the box with my desired list with a custom query built from my 2 entity tables, but I don't know how to get Access to create or update the Mapping table using this box.
what I want to happen is when I chose something in the box, a line is created (or changed) in the mapping table with all 3 columns being populated. first the LineItem_ID for the line I am populating, and then the DataType and Entity ID to reflect the proper mapping.
Can Access do this on its own? Or do I need to do this with VBA?
As requested by the OP converting my commend as an answer (with a little bit more detail):
By far your best option is to use VBA. I doubt there is another way and even if there is it would be so convoluted it would be unworkable and unmanageable.
This should get you started:
In the combo box properties go tot the events tab and in After Update or On Change (look up the difference between the two events to see which behavior you prefer) click the down arrow and select [Event Procedure], then click on the … button. This will create a VBA module for you complete with the function that runs when the selected event is triggered.
You can use DoCmd.RunSQL "[Access SQL INSERT statement]" to add records to tables.
You can use Me.[MyComboBoxName] to get the current value of the combo box. Similarly the value of anything else in your active form.
You can use DLookup to get the value of any record in your tables.
Hopefully these will give you a relatively quick start.

Access: Bind Combobox to recordset but disallow alterations to recordset on change/update

I'm facing an issue with Access Comboboxes that may be a terrible idea or be an improper use of the tool.
Let's say I have a form that shows metadata of a "Report" (things that are common in the report from day to day like reporter, project, target due date, expected total cost, etc...) with a Continuous subform of line items that are being reported (like cost of labor, materials, overhead expenses, etc)
In the backend I have 2 tables to represent this. The "Metadata" table and the "line items" table. When trying to capture individual items being reported the reporter is free to name the item as they see fit, however, in the system we want to map that reporter item naming to our internal item naming.
In order to do this I have a few helper tables and a mapping table to create this link. An 'Internal Line Item" table, a "DataType" table and a "Line Item Mapper" table.
The structure would look as follows:
- "Line Item" table with ID, Name, Metadata_ID and data (typical excel format)
- "Metadata" table with ID, and metadata common to all reports
- "Internal Line Item" table with ID and Name
- "Line Item Mapper" table with Internal_ID, LineItem_ID and DataType
- "DataType" table with ID and Name
So on to what I am having trouble doing.
I want to display a combo box in the subform for each row and the drop down will have a list of possible internal names that can be selected. I thought that by using an unbound box I could do this, but found that each row would get a copy of the same box (thus changing the selection for all rows at the same time).
I then tried to bind the box to the recordset using the ControlSource, but it changed id numbers when doing so (obviously not ok).
I then thought to tie the box to the Mapping table itself, but don't know how to couple it to the recordset as well...
What I want to do is bind this box to the recordset without allowing it to change any data in the "List Item" table because this box is meant to change the mapping table. I could then use the OnChange event to populate or update the mapping table with the proper data.
Is it possible to create such a binding (where the control is tied to a recordset, allowing me to get the LineItem ID, but not able to change the recordset while still allowing the user to interact with it)? Or is there a better way to approach this issue?
Turns out that I was just doing something foolish with my data model that lead to my troubles.
the full answer may be found here: https://answers.microsoft.com/en-us/msoffice/forum/msoffice_access-msoffice_custom-mso_2013_release/bind-a-control-without-data-alteration-access-2013/51a98460-6e1a-425d-8f7b-eba5f2825ba9?tm=1552503037022&auth=1&page=2
but the short of it is that I was improperly placing all my FK's in a single table trying to make a form of "mapping" table. I have since corrected my structure and have gotten my combobox to work as intended.

Lookup tables displaying number instead of text [duplicate]

I am trying to create a report putting a field called contact which has the name of a person. This name is linked directly to another table where I keep all the contacts.
For some strange reason, when I include this name (which in query view displays as the name of the contact), instead of the name appearing, the unique ID number is shown on my report.
As mentioned in the article cited in the above comment, you can use a Combo Box control on your report to do the lookup for you. To see how this can be done, create a new report based on the table containing the lookup field, then drag and drop that field onto the report. That will create a Combo Box control with properties that look something like this:
Row Source: SELECT [Clients].[ID], [Clients].[LastName] FROM Clients;
Bound Column: 1
Column Count: 2
Column Widths: 0";1"
You could use a similar Combo Box control on your actual report to display the client's name rather than their numeric ID value.
Another alternative would be to change the Control Source of the report's Text Box control to have it do a DLookUp() on the table. If the lookup field is named [client] then changing the Control Source of the Text Box to something like
=DLookUp("LastName","Clients","ID=" & [client])
would also work.
I wanted to add to the great answer by Gord:
When using a "web" database (started in Access 2007 I think), you cannot change a report's fields to ComboBox style, nor can you use DLookUp(). (web databases lack a ton of features)
The workaround for this, if you want to create a Web-Report that uses lookup fields, is to create a Web-Query first based on your Web-Table (all the Web-* stuff has a www planet icon over the logo, if you create a new Web-DB in Access 2007+ you'll see what I mean)
So, instead of Table -> Report, you'll have to do W-Table -> W-Query -> W-Report.
Then, the only thing you need to customize to get the data right is the W-Query. Start by trying to reproduce the look in the query to match what you want users to see in the report. Note that here in the query, lookups will work fine (instead of the unique ID's, you get field names like you want). However, this will not carry over to the report. To do that, you gotta get the actual text field name you want into the query:
You should already have one table in your query; start by adding the table that your first lookup field points to. For example, the table I want to print is called Stock_Boards, and it has a lookup field called PCBID_lookup that points to the table Stock_PCBs.
Since you're using lookup fields, there should already be a relationship line between the two tables when you add the second one. If there isn't, something has gone horribly wrong.
Now, see how that line connects two fields on the two different tables? For example, I've got my PCBID_lookup field on my Stock_Boards table, which connects to the ID field on my Stock_PCBs table. If I created a report from this now, PCBID_lookup would be a number, a number that correlates to the ID of a record on Stock_PCBs.
To fix it, I will add the name field I want to show up on the report. In my example, that happens to be a Part Number, rather than the ID. I add the PartNumber field from my Stock_PCBs table to the query, and remove the PCBID_lookup field of the Stock_Boards table from my query.
Since PartNumber is what I want to show up on my report, it effectively replaces the original field (PCBID_lookup)
Repeat for all lookup fields you want in your report.
I had 1 more: I removed the Status field of the Stock_Boards table (which was an ID/Lookup) and added the 'Status' field from the Status table (which was the actual text name)
When finished, your query should look exactly how you want the data to appear, without any special tricks or asking Access to do something unnatural. Save your query, and create a web-report from it. Done!

Can I make one form to get record data from multiple (unrelated) tables in Access?

I know only the basics of Access, so I am having trouble figuring out how to make a form that will access multiple unrelated tables.
My problem:
I have several tables which describe different card collections. There is no way that I want to link them, even if I could, e.g. by card names. This is because I want to keep the listings separate. I do, however, want to create one form that will access them all, so that I don't need to fiddle about clicking on different forms every time I want to update a card database. The more tables I include, the less practical this would get, anyway. I've tried looking this up and there are several sites which seem to suggest sql-like statements as solutions, but frankly these fly over my head - I don't even know where I'd write them!
So what I want is one form that has a combo box menu to select the table that I want to edit, then another box to select the card that I want to see and hey presto I can edit the details of that card. I can do this if I make one form for one table, but I don't know how to do it for many tables. I would also like it to check for new tables should I add them in. E.g. cards have different series that come out, so when a new one comes out I will create a new table for it, add the cards and so on...
I realise this is probably quite fiddly, especially in Access, but if anyone can give me some guidelines on how to do this it would be much appreciated. (I'm using Access 2007)
To answer your question:
Use subforms. Create few subforms and your combobox and hide/show the forms as you desire.
Better way to do it:
Creating separate tables for each card type is quite a bad practice. If the cards share features like MonsterName, MonsterPowerType or whatever, you should create another table like card_types and add a card_type field to the cards table. Then if you need to get only Pokemon cards create query with card_type_id = xx or card_type_name = "Pokemon" criterias.
This way you only need one form and you can change the card_type criteria with use of your combobox.
This is quite old, but it might help others. I did figure a way to do exactly what you asked
I only have access 2016, so things might be in a different place, but not that much.
First, create all the tables for each of your decks. Make sure you have in the first column : unique ID, second column the name of the deck (it's going to be the same for each entry in this deck) this is going to help us. The third column the name of the card. The other columns will contain your other values of your card, but for my example it doesn't matter.
I'll name them like this
column name
1 unique_ID
2 DeckName
3 CardName
Now, in the tab "create" choose "Query Design". Then in the tab "home" in the seciton Views, choose SQL.
in the blanck section enter this
I have 2 tables :
Table1 and Table2
SELECT Table1.DeckName FROM Table1 UNION SELECT
Table2.DeckName FROM Table2;
You have to add each table and add a UNION between each. You finish the sentence with one semi coma only ;
Click run and you should get all the DeckName.
Save your query and close it.
Now, we want the combobox to help us choose between the different decks.
in the tab "Create" choose "Blank Form". Go to "home/views" choose "design". In the "design" tab, choose the combobox. You can click cancel and skip the wizard
In the property, click "rowsource" and select the query you have created.
Name it Cmb_Deck
Add a second combobox
Name it Cmb_Name . property "Column Count" put "2" because this combobox will show the name of the card, which is column2 in our tables.To be a little bit fancy, we will hide the first column, in the property "Column Widths" put "0";1"" (first column 0inch, second column 1inch).
Drag any of the table you have create into the form and click cancel when the wizard appear.
Name it TableResult
Now that the layout is created, we need to change the table according to the combobox Cmb_Deck.
In the Cmb_Deck property go in the event section and choose "After Update" click on the "..." and choose Code Builder
In this Visual Basic editor window : delete everything that is there and enter this
Option Compare Database
Private Sub Cmb_Deck_AfterUpdate()
TableResult.SourceObject = "Table." & Cmb_Deck.Value
Cmb_Name.RowSource = "Table." & Cmb_Deck.Value
End Sub
Private Sub Cmb_Name_AfterUpdate()
Me.TableResult.Form.Filter = "([" & Cmb_Deck.Value & "]." & "[CardName]=""" & Cmb_Name.text & """)"
Me.TableResult.Form.FilterOn = True
End Sub
Now back in access, select your combobox Cmb_Name and go into property event/afterupdate and choose "[Event Procedure]
Now in your form, go to home/views and choose Form Views. First choose a deck in the first combobox, then choose the name of a card in the second combobox. Now the table underneath, shows only the card that you want to see.
I hope this helps
-Mathieu Paquin

microsoft access control source from a table in another group in a report

I am new to Microsoft access, and I am trying to make a report from the data in 2 tables. I am using text boxes and setting the control source to the value from the table in the property sheet. All but one works fine, the one from the other table. The the value pops up with a "Enter Parameter Value" then the name of the main table when I switch to report view. The control source for the text box is "=[Main table]![Due date]" I made it with the little Expression maker in Expression builder. What am I doing wrong?
I found something close but it did not help me fix it link.
A form/report can only have one Record Source. Create a query that combines the two into a single query, and then use that as the form/report's Record Source.
If you are creating a form and you want the underlying table to be editable, join the tables together and make sure each of them has a primary key.