Filter for calculated field

Hello everyone! In a filament table I have a field called TTF (Topical Trust Flow) which has a dynamic numeric value depending on the topic chosen by the user. I would like to perform a filter on this value, but I need the filter not to be "custom" in the Livewire component page but rather to be a filament filter. The point is that this calculated field is not saved in the database and so I would not know where to retrieve this information with the classic query method. Thank you very much for any help you can give me. Attached is the code for the column.
No description
5 Replies
awcodes
awcodes5d ago
Currently, because filters are tied directly to eloquent, I think the only way to do this would be with a virtual column on the table.
Davide Cariola
Hi, thank you for the response! I was wandering about an SQL view. When you talk about a virtual column you intend in filament or in the DB?
Jany
Jany4d ago
You can also adjust main query to calculate that column, or have virtual sql column or sql view, or havinng job to calculate that column from time to time
Dennis Koch
Dennis Koch4d ago
Virtual Columns are a SQL concept.
Davide Cariola
Thanks everyone. Tomorrow I'll work on it and let you know!