Topic
  • 5 replies
  • Latest Post - ‏2012-03-01T21:08:48Z by PeterWeir
PeterWeir
PeterWeir
51 Posts

Pinned topic Does ListAttributeSum actually work?

‏2012-02-29T02:40:46Z |
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:

=ListAttributeSum("350","014","353","15",'Related items',"listen_to=Cost")
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?
Updated on 2012-03-01T21:08:48Z at 2012-03-01T21:08:48Z by PeterWeir
  • magho
    magho
    5 Posts

    Re: Does ListAttributeSum actually work?

    ‏2012-02-29T08:33:24Z  
    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

    Attributes:

    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.

    Regards

    /magnus
  • PeterWeir
    PeterWeir
    51 Posts

    Re: Does ListAttributeSum actually work?

    ‏2012-02-29T21:28:53Z  
    • magho
    • ‏2012-02-29T08:33:24Z
    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

    Attributes:

    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.

    Regards

    /magnus
    Hi Magnus thanks for the prompt reply.

    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)

    Many thanks
    Peter
  • mgarces
    mgarces
    12 Posts

    Re: Does ListAttributeSum actually work?

    ‏2012-03-01T03:59:20Z  
    • PeterWeir
    • ‏2012-02-29T21:28:53Z
    Hi Magnus thanks for the prompt reply.

    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)

    Many thanks
    Peter
    Peter,

    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
    magho
    5 Posts

    Re: Does ListAttributeSum actually work?

    ‏2012-03-01T07:50:40Z  
    • mgarces
    • ‏2012-03-01T03:59:20Z
    Peter,

    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.
    Hi,

    An easier way to find the internal id of a view (or any element in Focal Point) is to hover the the top edit icon in the attibute list, the "Edit All" icon. If you have the Status Bar visible (the bottom bar in your browser), it will display "javascript:editElement(XXX)", where XXX is the internal id of the view (or element).

    /Magnus
  • PeterWeir
    PeterWeir
    51 Posts

    Re: Does ListAttributeSum actually work?

    ‏2012-03-01T21:08:48Z  
    • magho
    • ‏2012-03-01T07:50:40Z
    Hi,

    An easier way to find the internal id of a view (or any element in Focal Point) is to hover the the top edit icon in the attibute list, the "Edit All" icon. If you have the Status Bar visible (the bottom bar in your browser), it will display "javascript:editElement(XXX)", where XXX is the internal id of the view (or element).

    /Magnus
    Thank you both very much for this! I have got it sorted now (the view ID was the problem).

    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.

    Problem solved!

    Peter