issue with reject(fn!isnull, 'array of arrays') function on a data generated from an expression rule

 Hi Community,

I have a strange problem with the reject function. I am getting an error when I work with the data generated with my expression rule. If I do a copy & paste of the data generated, the function does not give me an error but I am not getting what I expected.

A further description of the problem (as maybe I am just taking the wrong approach), I have on CDT on which one of the values is the id's of another CDT. I wanted to count how many times the second CDT is used, so I can have a graphical representation in a form of a pie chart. My expression rule gives returns the data in a way that is easy to work on graphs, like the pie chart below. 

When I call the expression rule, I get the data like this:

{{}, {}, {}, {}, {}, {}, {}, {}, {"Outbound", 1}, {}, {"Mudcakes", 2}, {"Happy Industries", 2}, {}, {}}

 Which means that "Outbound" appears 1, "Mudcakes" 2 and "Happy Industries" 2

On the pie chart, the values "{}" appears like [Series 1], [Series 2] and so on. I want to get rid of those empty arrays.

Then, I try to use the function reject, like below

reject(fn!isnull,rule!APP_myExpresionRule), it troughs me an error

Expression evaluation error at function 'reject': Incorrect number of parameters for function; expected 1 parameters, but found 0 parameters

Now, when I copy the data generated with rule!APP_myExpresionRule, 

reject(fn!isnull,{{}, {}, {}, {}, {}, {}, {}, {}, {"Outbound", 1}, {}, {"Mudcakes", 2}, {"Happy Industries", 2}, {}, {}})

I get this:

 {"Outbound", 1, "Mudcakes", 2, "Happy Industries", 2}
 
which is not what I am looking for, as I would expect to have something more like this:
i
{{"Outbound", 1},{"Mudcakes", 2}, {"Happy Industries", 2}}
 
Below the pie chart as it looks now:

 

 

Any suggestions?

 

Thanks!

Manuel

  Discussion posts and replies are publicly visible

Parents
  • Hi Manuel,

    What i would suggest it may not be the best answer, Have you tried adding key value to the array of elements?
    Find the following example.
    reject(fn!isnull,
    {
    {}, {}, {}, {}, {}, {}, {}, {}, {
    item:"Outbound",
    id: 2
    }, {}, {
    item:"Mudcakes",
    id: 2
    }, {
    item:"Industries",
    id: 2
    }, {}, {}
    }
    )

    This will give you the output you need.

    You can even test how the values are getting passed by using the a!foreach()
    So if you do
    a!foreach(
    items: Your array,
    expression:
    fv!item)

    This will remove the blanks by default and will give you {"Outbound", 1, "Mudcakes", 2, "Happy Industries", 2}.
    If you use keypaired values will give your desired output also.

    The issue is because it treats them as different elements even if they come within an array of arrays it counts them as separate elements if they don't come within key paired values.

    Hope this helps. I'm sure you can get better suggestions on your problem.
  • Thanks for the Idea, but it is not the right solution. For reaching that solution the best would be to use touniformstring() and then the reject function. The problem there is that then I get a flat array, which does not work for the graphical representation of the pie chart.

    Rather than having and Index, the solution was to make it a datasubset.

    Thanks for the suggestion.

Reply
  • Thanks for the Idea, but it is not the right solution. For reaching that solution the best would be to use touniformstring() and then the reject function. The problem there is that then I get a flat array, which does not work for the graphical representation of the pie chart.

    Rather than having and Index, the solution was to make it a datasubset.

    Thanks for the suggestion.

Children
No Data