I have Projects with related Items. In my Projects element I need to calculate two sums for Item elements listed in an Incoming Links attribute. Items in the list can have a status of either "Current" or "Archived". I need to calculate a total for both states.
I can use LinkListAttributeSum to get the overall total.
Theoretically I can create the two totals using two views which show only Items of the correct state, and ListAttributeSum... but I can not get this to work (and PLEASE do not tell me to read the helpfile! Trust me I have been doing that all day)
The relevant attributes for my "Current" items are:
Related items (ID 350 in my Projects module)
Peter (user ID 15)
Cost (ID 353 in my Items module)
Current Items (view ID 014)
The rule I am using is:
Can anyone tell me why this gives me a result of 0 if used in an integer attribute or is blank if used in a text attribute?
Pinned topic Does ListAttributeSum actually work?
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-03-01T21:08:48Z at 2012-03-01T21:08:48Z by PeterWeir
magho 2700033TMT5 Posts
Re: Does ListAttributeSum actually work?2012-02-29T08:33:24ZThis is the accepted answer. This is the accepted answer.Hi,
To use ListAttributeSum with your setup you need 2 views and 2 attributes.
View 1: All Items in the Items module whose Status is Current
View 2: All Items in the Items module whose Status is Archived
Current Cost Sum (Integer or float - same as Cost)
Archived Cost Sum (Integer or float - same as Cost)
Try the following:
Verify your view id. "014" seems like the displayed Unique ID for the view - the internal id is needed.
Verify that the user Peter actually have the global id "15" <- this indicates that Peter was the first user added to the database.
BR in Current Cost Sum:
=ListAttributeSum("350","<view 1 id>","353","<peter global id>",'Related items',"listen_to=Cost", "listen_to=Status")
BR in Archived Cost Sum:
=ListAttributeSum("350","<view 2 id>","353","<peter global id>",'Related items',"listen_to=Cost", "listen_to=Status")
Note that there is a listen_to on the status attribute, this is to make it recalculate when the status of an item changes (all attributes used as view rules of the views used must have a listen_to)
The reason you get a 0 is that there are no values defined, found or all values are 0. If you are running the BR in a text (or date) attribute the result will always be "" or ?. The BR must reside in an integer or float attribute.
Re: Does ListAttributeSum actually work?2012-02-29T21:28:53ZThis is the accepted answer. This is the accepted answer.
- magho 2700033TMT
I had only focussed on one of the states in my question as I figured if I can get it working for one state I can for the other one as well. I do have two views and two attributes.
Looking at your sample the view ID seems to be the only thing I may have wrong. Can you tell me where to get the internal ID for a view? I had a hard enough time finding it for the user! (and yes 15 is the correct user ID. I would have been the first user in the database)
I will also add the listen_to for the status once I have the view ID sorted.
Re the 0 result - the linked elements definitely have values (ie not blank or zero)
mgarces 270001R47X12 Posts
Re: Does ListAttributeSum actually work?2012-03-01T03:59:20ZThis is the accepted answer. This is the accepted answer.
- PeterWeir 270003G8UG
Yes it looks like you may not be using the correct internal id for the view. You can do this by:
1. Open the View in View Manager
2. Right click on the page
3. Select: This Frame>Frame Source (depending on your browser, the option might be different. I'm using firefox)
4. The html source doucment will display. Search for: elemID
The internal ID is the value assigned to this variable in the html source code. See the screen shot that I have attached.
magho 2700033TMT5 Posts
Re: Does ListAttributeSum actually work?2012-03-01T07:50:40ZThis is the accepted answer. This is the accepted answer.
- mgarces 270001R47X
Re: Does ListAttributeSum actually work?2012-03-01T21:08:48ZThis is the accepted answer. This is the accepted answer.
- magho 2700033TMT
Thank you Magnus for the tip on how to easily find the internal ID. I had previously used the technique of viewing the frame source to find the internal user ID, but your way is obviously much easier. It would have helped if the help file actually explained how to find this critical information.