Forum Discussion

Millstone1998's avatar
Millstone1998
Frequent Visitor
1 year ago
Solved

Retrieving the current page filters

Hi, If I pass a filter to a report in a URL it becomes a page filter.  Is there any way to retrieve that filter condition when there are no rows matching the condition?  As there are no rows I can't...
  • johnt75's avatar
    1 year ago

    I don't think that this will be possible because of the way filters work. Even if you specify the condition as a boolean, filters are always tables of values which already exist in the data. For example, if you specify 'Table'[Column] < 5 as a condition, that might be translated into a list like { 0, 1, 2, 3, 4 }. But if you don't have any entries where the value is 3 then the list would be { 0, 1, 2, 4 }.

    Given that, if you try to use as a filter a value which doesn't exist in your data then Power BI will basically just throw that value away.

    Having said that, you might be able to detect the fact that a missing value was passed in, even if you can't detect what the value was. You could create a measure like

    Missing value used as filter =
    IF (
        ISFILTERED ( 'Table'[Column] ) && ISEMPTY ( FILTERS ( 'Table'[Column] ) ),
        1
    )
    

    This checks that there is a filter applied to the column, but the values or condition applied don't match any of the existing data.