Forum Discussion
Adding filter via code to an existing table on desktop - how?
- 1 year ago
Hi Anonymous You can try by creating a measure using SELECTEDVALUE to capture the slicer date (e.g., SelectedDate = SELECTEDVALUE('DateTable'[Date])). Then, create another measure to filter rows, such as FilteredTable = IF(MAX('YourTable'[DateColumn]) = [SelectedDate], 1, 0). Add this measure to the table visual’s filters pane and set it to is 1.
Hi Anonymous,
Thank you for reaching out to Microsoft Fabric Community.
Make sure the fact table has a proper relationship to the calendar table on a date field.
Use this below mesure:
ShowPreviousMonthRows =
VAR SelectedMonth = SELECTEDVALUE('Calendar'[Month])
VAR TargetMonth = SelectedMonth - 1
VAR RowMonth = MONTH(MAX('Yourtable'[Date]))
RETURN
IF(RowMonth = TargetMonth, 1, 0)
Add this measure to the filters pane of the table visual and set the filter condition to 1.
This will ensure the table only shows rows from the month prior to the one selected in the slicer.
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thanks and regards,
Anjan Kumar Chippa