DAX Filter unrelated tables

rpmitchell

New Member
Joined
Jun 22, 2011
Messages
43
Hello. I am trying to run a calculation that uses only certain rows from an unrelated table. Here is the scenario:
I have two tables with account numbers. Each account number is repeated multiple times in each table. The account value is different in each table. I built a pivot off Table1. I want a sum of the values in table 2, for all accounts in table 1, that happen to be a part of the pivot table filter context. The actual account number isn't on the pivot, just attributes of the account. I've tried:

Calculate([Sum(Tbl2[Value],
Filter(Tbl2,Tbl2[Account] = Tbl1[Account]))

but it doesn't work. It can't determine the value of the Tbl1 account in the current context, blah, blah, blah...
Any ideas on how to fix this formula?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Both these tables are data tables, so they have to be on the many side of any relationship. Why not create a new lookup table that contains a superset off all account numbers. Then join both of your current tables to this new table, then put the account number from the lookup table in your pivot. You can then create 2 simple calcs

val1=sum(table1[value])
val2 =sum(table2[value])
 
Upvote 0
Both these tables are data tables, so they have to be on the many side of any relationship. Why not create a new lookup table that contains a superset off all account numbers. Then join both of your current tables to this new table, then put the account number from the lookup table in your pivot. You can then create 2 simple calcs

val1=sum(table1[value])
val2 =sum(table2[value])

Thanks Matt. The problem with this is that I have close to a million account numbers, so I don't want them on the pivot. I want an attribute of the account, for example "Account Age", "Patient Type", "Payor, etc". These attributes may or may not match in the two tables. I've thought about a bridge table, but I think the maintenance on it would be massive. I'm leaning towards a Calculated column in table 1 with a Lookupvalue(). I could match the required attributes of each account and return the value I need. I just wonder how it would affect my model performance. Is it ok to run that kind of calc column with a million rows?
 
Upvote 0
If the attributes don't match, how can you put them in a pivot table and aggregate data from 2 tables? If they don't match, what is the point of a calculated column? So just add the attributes to the lookup table and add the attributes to the pivot.
 
Upvote 0
why don't you use the Table2 to build a slicer with the Table2's attribute. This will save you a lot of trouble.

If you have a combo set, why not put the parameter on Table 1 and just display the slicer with the key. When user select the key, the set of parameter will be returned.

For your error message, you need to put a dummy formula to wrap around Tbl1[Account]. Maybe you can try FirstNonBlank().
 
Upvote 0

Forum statistics

Threads
1,216,031
Messages
6,128,424
Members
449,450
Latest member
gunars

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top