Excel Data Model without using PowerPivot

折月煮酒 提交于 2019-12-12 11:20:56

问题


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.


回答1:


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




回答2:


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)



来源:https://stackoverflow.com/questions/40614801/excel-data-model-without-using-powerpivot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!