Filter table based on multiple values

I have a transaction table that is used to record data for 4 stores. Each store has a 4 digit store number and each transaction is date coded. I am trying to filter the data based on store code and the month of the transaction date. I can get the filter to work with the store number, but I can't get the syntax right to also filter by transaction month. Following is the set property I am using:
${result.Where(r => r.Deals_StoreNo == 4675)}

I tried using AND a few different ways and can't seem to get the syntax right. Here was my first try.

${result.Where(r => r.Deals_StoreNo == 4675 and MONTH(r.Deals_DealDte)=MONTH(GETDATE()))}

help please!

have you tried this syntax?

I am looking for the syntax in a "set property" handler. The first syntax I used works, until I try to add a second filter property using "AND". I can't seem to get the syntax right.

Not sure what type of filter you tried but it worked for me.

image

1 Like

Yes, I know that I can filter it manually in the grid, I am trying to filter it programatically using a set property


I just need help expanding the value to include filtering by two field values. I can make it work on one, but can't seem to write the proper syntax to filter by the second field.

You can use the && C# operator and add a second condition e.g.

${result.Where(r => r.Property1 == "Value 1" && r.Property2 == 2)}

Perfect, that's what I was missing! Followup...the second field is a sql date field...I need to extract the month and filter by the month of the current date...also can't seem to get this data extracted...any help is appreciated.

I recommend checking the properties of the .NET DateTime - Radzen should map SQL date columns to DateTime.

I have it working to filter by today's date, but can't extract the month. Also when I set this filter, some of the grid filtering options no longer work. I can filter by a single day, but not a range or greater than...is there a way to reset the filter?

Why can't you extract the month? What is the problem?

I am not sure what this means.

You can use >= and <= operators to to compare dates. This however isn't in the scope of Radzen support as it is general .NET / C# programming question.

So I tried this route. Couple issues...doing it exactly like you showed except with a different month. Filters fine on the first filter, but goes blank on the second filter.



Also tried just to filter on a single date

It Filters one day off?

What am I doing wrong?

You might need to use a date range or ignore any time element that might be present in the column. Also, ensure the dates are comparable e.g. utc or local

1 Like