Solved

Related in Powerpivot - a one way street

Posted on 2015-01-01
12
103 Views
Last Modified: 2015-01-05
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.
0
Comment
Question by:agwalsh
  • 6
  • 6
12 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40526621
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
 

Author Comment

by:agwalsh
ID: 40526655
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
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40526895
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:agwalsh
ID: 40527357
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
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40527367
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
 

Author Comment

by:agwalsh
ID: 40531471
@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
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40531473
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
 

Author Closing Comment

by:agwalsh
ID: 40531487
This was driving me nuts but Phillip's elegant solution sorted it for me. Very happy with it :-)
0
 

Author Comment

by:agwalsh
ID: 40531511
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
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40531515
0
 

Author Comment

by:agwalsh
ID: 40531600
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
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40531605
If you want one negative value to outweight all the positive ones, then yes.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dynamic Chart Range 13 36
Best Excel  formula for  this scenario 2 38
Data Copy 4 24
Formatting Excel Data as Table from Access 11 12
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question