Filter Data Issue

Hi,

 

I have one data set which i am trying to filter on basis of some status. If status of any records in "HELLO" then i am picking date of that records and filtering out that date from union of dates by using difference() function. But this trick is not working in case of single row data.

Kindly check where i am doing wrong in this.

 

local!date1: union(
ri!dataset[wherecontains(
{
"HELLO"
}, ri!dataset.status
)].date,
ri!dataset[wherecontains(
{
"HELLO"
}, ri!dataset.status
)].date
),
local!date2: union(
ri!dataset.date,
ri!dataset.date
),
local!filterdate2: difference(
local!date2,
local!date1
),

  Discussion posts and replies are publicly visible

Parents
  • I'm not quite sure on what you want to achieve here. Could you tell us a bit more on what you are trying to do?
  • Basically i need to filter dates from one array on basis on some condition. Here i have filtered two dates array . One is master another one is child one. Now i want to remove child from master. Its working if i have number like Master(5)- CHild(3) so end array would be 2. But i know i am using wrong function ( difference() function). Because child records and master records are getting populate from same array set. So if i have one record then in master n child count of record would be one only. In this case this difference() function will not work. It will return single record but it should return blank array as i want to remove child record from master one.

    Parent Array -8

    Filtered Master Array1 -5
    Filtered Child Array2 - 2
    difference(Array1,Array2)-> 3

    Parent Array -1

    Filtered Master Array1 - 1
    Filtered Child Array2 - 1
    difference(Array1,Array2)-> 1- Which is wrong. It should return blank array.

    In this case which solution you will provide to me.
  • 0
    A Score Level 1
    in reply to sauravk
    I am neither so sure of what you are trying to do.

    Anyways, if you said that it works for arrays but not for single set of CDT, why then don't start with an if statement that counts if it has more than one element or not - with the count function?

    When working with arrays, many times it is better to work with single elements instead and work with a a!foreach for each of the arrays.
  • I tried to replicate that behaviour with local variables and did not encounter the issue you described.

    Have you attempted to write the filters into local vars?

    Else, if its merely an edge case, Manuels answer has merit.
Reply Children