Skip to main content

Hi, I have been trying to build a filter in the new view based on a variable - but couldn't get it to work.

 

Target filter should look like this (and the explicit example below works):

 

FILTER "DEV_CUSTOMER_HIERARCHY"."KUNNR" in ('9000100043','9000100188','2000000007')

 

The variable contains a list of strings, each string enclosed by single quotes, separated by a comma, see below - as I couldnt make it work I tried different versions in respect to start and end of string (with or without parentheses and single quotes)

 

('9000100043','9000100188','2000000007')

'9000100043','9000100188','2000000007'

9000100043','9000100188','2000000007

 

I didn't get any of these filter expressions working:

 

FILTER "DEV_CUSTOMER_HIERARCHY"."KUNNR" in ${path_from_top}

FILTER "DEV_CUSTOMER_HIERARCHY"."KUNNR" in (${path_from_top})

 

the filter is flagged with a red square on the left, but doesnt break the view

 

interestingly - if I artificially add an error into the filter to get an error message, the error message shows the parsed string. The parsed string displays backslashes within the string for the single quotes - which might be the reason the code doesnt work as intended.

 

Any insights how I could make a filter work that wants to check if a string value (from my table) is in a list of values that is stored in a variable?

 

Regards

Axel

 

image 

 

 

 

forgot: the filter using the variable always returns an empty results set, while the explicit one returns three results as expected


@isabella.apfel @david.toro @enrique.guerr11 - any chance to help here?


Hi dear @Axel Bühler 

 

thank you for your question, I have tried to replicate your use case, in this scenario I'm filtering a table that contains names:

imageI created a view variable of type string containing the names I want to filter with:

imageHere is the table, where I have the column with the names and a filter in the component:

image.pngFinally you can see the output:

image 

Let me know if this works for you!

 

Bests,

David


Hi, @david.toro - thanks a lot for your fast response! What you show is what I expected. But ... something is off ...

 

Something seems broken when then populating the variable from an attribute, seems to be about the handling of the single quotes. I added a default value (same as you did) to the filter. Below screenshot shows no value selected, so current value = default.

 

image 

I had to rebuilt the table from scratch - no idea why - it now works with the defaults BUT it doesnt work when I assign a value from an attribute to the variable ... and if you check the value of the variable you suddenly have the backslashes ...

 

image 

image 

Regards

Axel


@Axel Bühler 

 

 

I have extended the setup to include an input dropdown with multiple selection that writes to the variable, as you can see the output is as expected.

 

Can you check if this setup works for you too? Else I'd propose to reach out to support to dig deeper on what is causing the issue.

 

PD: Something you might want to check, is making sure that in the input dropdown you use the option "Load items" and select the table were the items you want to filter with are. As you can see in my setup each item is a row on that table, I think you might have multiple items per row appended in a string, this does not work.

 

names_test 

Bests, David


Hi, @david.toro 

 

thx for getting back - I rewrote the data model and created linking tables - this solution works but needs more effort in data integration.

 

It might be interesting to think about how to enable pulling a string from an attribute value that serves as PQL code. In this case an attribute value would serve as the list of items that can be used in the table.field IN ('yyy','ZZZ') statement - 'yyy','ZZZ' could be pulled from the attribute value.


As an extension to this idea you could also consider to enable selection of a single record and storing it in an object variable - this could allow for easy access to all attributes of the selected record and using them for e.g. filtering.


Reply