Related in Powerpivot - a one way street

hi Folks
I've got 3 tables - let's call them Table1, Table 2 and Table 3 (all connected many to one) to a Chart of accounts table. Relationships all set up and working. I now want to use Related to pull a value from Table 1 into my chart of accounts. I get an error message. When I try Related in the other direction i.e. pull in something from Chart of Accounts into Table 1 - it works fine...any suggestions/workarounds? Thanks.
LVL 1
agwalshAsked:
Who is Participating?
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
I am not familiar enough with your fields and relationships to be able to help at present.

Have a think about what the fields are that you need, and the relationships between them (e.g. one-to-many).

Here's a possible solution:

=if(and([Reclassification]="Reversible",SUMX(RELATEDTABLE('SH_TB_Oct-14',[Sum of  Nov 2014 PTD actuals]))<0),"Current Liabilities",[Account])

However, you may need to convert Account to a string, because you are outputting both a string and a number, depending on the result. Try changing "Current Liabilities" to -1 and see if you can get it to work first, then try re-inserting the string.

So try

=if(and([Reclassification]="Reversible",SUMX(RELATEDTABLE('SH_TB_Oct-14',[Sum of  Nov 2014 PTD actuals]))<0),-1,[Account])
0
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
If RELATED works in one direction, then you probably need RELATEDTABLE in the other, as you are probably going from the one to the many direction, instead of the other way round.

See http://msdn.microsoft.com/en-us/library/ee634226.aspx for examples and the syntax.
0
 
agwalshAuthor Commented:
hm, OK, this is what I have and I'm still getting an error message:
=if(and([Reclassification]="Reversible",RELATEDTABLE('SH_TB_Oct-14',[Sum of  Nov 2014 PTD actuals])<0),"Current Liabilities",[Account])

What I want to happen is that if the phrase "reversible" is in the Reclassification column AND the value of [Sum of  Nov 2014 PTD actuals] in the 'SH_TB_Oct-14 table is negative, THEN I want to see "Current Liabilities", otherwise whatever is in the account field..
I suspect I'm getting the RelatedTable syntax wrong....
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
RELATEDTABLE returns a table, but your expression can only deal with a single value.

Therefore, you need a SUMX() or other aggregate function around it.
0
 
agwalshAuthor Commented:
OK, so what would you suggest for the formula above? I want the formula to switch the categorisation of a transaction from asset to liability assuming it's "reversible" and a minus value...thanks :-)
0
 
agwalshAuthor Commented:
@Phillip Burton...reader, I got it working :-)
You were right about the string thing.  This is what worked..I think you were missing a bracket after the RELATEDTABLE function....:-)
=if(and([Reclassification]="Reversible",sumx(RELATEDTABLE('SA_TB_Oct-14'),[SAA_Nov_14_YTD_Act])<0),1,23456)
so I just put in numbers instead. It wouldn't work with [account] or "current liability" but it would work with numbers.
I tried reinserting the string - but it didn't like that either. So do I now need to put in another column that says if this is a -1 enter current liability, otherwise enter whatever is there...presume that would be a straightforward if statement? Thank you so much for this by the way :-)
0
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
You're welcome - and yes.

Bear in mind that SUMX is a sum product, so you have to decide what to do if there are multiple entries.

Do you want the maximum entry, or does one negative value and several positive values stop the lot from working - or what?

It may be that you will only have a 1-to-1 relationship, but because the relationship is set up for a one-to-multiple, it is expected more than one row. So, what do you want to do if there are multiple values?
0
 
agwalshAuthor Commented:
This was driving me nuts but Phillip's elegant solution sorted it for me. Very happy with it :-)
0
 
agwalshAuthor Commented:
Well, it's a one to many relationship from TB to Chart of Accounts.  What I want it to do is that if a value meets those two conditions i.e. marked as reversible and is a liability in the TB table i.e. minus, that what appears in the calculated column is "Current liability". The idea is that there are balances which swing from current asset to current liability depending on the balance e.g. certain types of taxes. These are marked as reversible in the chart of accounts and I want this reflected in the balance sheet.
0
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
0
 
agwalshAuthor Commented:
Hi Phillip
Of course I saw that as minx first i.e. "an impudent, cunning, or boldly flirtatious girl or young woman". LOL
But I presume you mean MinX :-) so you think I should use that instead of SumX in the formula? Thanx :-)
0
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
If you want one negative value to outweight all the positive ones, then yes.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.