cancel
Showing results for 
Search instead for 
Did you mean: 

Session Variable Query Filter Not Working

mkrieger
Ranger

I am trying to create a session variable that returns a specific column value (say column X) from the row with the most recent date value. However the filter expression in my query does not work at all and I am returning all X column values.

Why is my query expression not working?

query(
          schema.table.x_column,
          schema.table.date_column = max(schema.table.date_column)
)

returns [x_value1, x_value2, etc]

 

2 REPLIES 2

anurag
Employee
Employee

@mkrieger query function works at row level and aggregate functions will not work.

You need to aggregate data in a table and then query that table in query function.

Please review this video for a similar use case:

https://www.youtube.com/watch?v=9CdKnTh2CiM

shashidhar_sris
Partner
Partner

Hi @mkrieger ,

Here is the solution from my end.

1) I took sample data like below.

shashidhar_sris_0-1694709882172.png

2) Before creating the session variable, created an IAT table because session variable is returns only string type values.

shashidhar_sris_1-1694710065366.png

3) Creation of a session variable on date (from IAT table) using dateformat.

shashidhar_sris_2-1694710315951.png

4) Finally, applied that session variable in the prompts.

shashidhar_sris_3-1694710408934.pngshashidhar_sris_4-1694710652448.png

Regards,

Shashidhar.S