Count selected members of an entity in procedures

Options

Hi,

 

is it possible to count the selected members of an entity in a procedure?

I want to use it as a button function in a screen.

For example, the procedure is supposed to find out when the current user calls the procedure, how many salesmen are available.

 

Kind regards

 

Jonas 

Tagged:

Answers

  • Alexander Kappes
    Options

    Dear Jonas Trompeter,

     

    thanks for your request.

     

    In general this is possible using Temp Cube structured to the entity which has to be count.

     

    When your final selection is performed you just have to run additional DataFlow which just writes the value 1 for each element.

     

    The total of this cube is your count.

     

    Please take care, when more users are working inside the application, that you also insert user dimension into your cube and that the cube will be cleared initially, otherwise your count isn´t valid.

     

    Hope it helps

     

    regards


    Alexander Kappes

  • Paul Wyatt
    Paul Wyatt Customer
    First Comment 5 Up Votes 5 Likes First Anniversary
    edited March 2020
    Options

    Hi Jonas Trompeter

     

    You could display the total number of selected entity members using native BOARD objects, namely a dataview using the ranking function and a label to display the SUM of the selected entities.  This solution would be fast, simple and dynamic; updating whenever the selection changes. 

     

    I do not know for what you use your procedure but if a part of it returns a count value, you could simplify and use the approach that follows:

     

    The image below is a simple example of as screen with:

       a.   Selector

       b.   label*

       c.   dataview*

    (* I've formatted the label and dataview to appear as one object.)

     

    By selecting any number of cities, the SELECTED CITIES count automatically updates and the list of selected cities is displayed without procedures or having to refresh the screen.

     

    image

    The only calculation involved is the dataview used to identify the number of selections and also the list of those selections.

     

    Construction of Dataview

    The dataview uses any cube that has the key entity to be counted within the hierarchy.  However, there are several other ways to achieve this, such as creating a single count cube with only the dimension required to be counted.

     

    The dataview, once created can be formatted to appear as a list as well as being copied into a label to display the total number of selected members. 

     

    1a.   The dataview has a minimum of 3 blocks; Cube, Ranking & Algorithm:

     

    image 

    1b.   To list the entity members selected, include the entity in the row axis, and switch off Down Totals.  Also, hide all three blocks.

    image

     

    1c.   Copy the layout

    image

     

    2.   Construct Label

       2a.   Place a label on the screen and enter the setup:

    image

    2b.   Select [Layout] > Paste Layout

     

    2c.   Select the filters tab and

       1.  insert block c into the SORT By

       2.  Edit the value in the Keep Top area to [ 1 ]

    image

     

    You can now format both the dataview and label as you need.  An expansion of this approach could be to use a dedicated count cube to hide the label if no selection has been made.  To achieve this, you could save the maxvalue of the entity count and hide the label if 1/b*100 = maxvalue.

     

    Without understanding what your procedure is doing, I hope that this may be of interest.  I'm happy to address any queries you may have.

     

    regards,

     

    Paul Wyatt