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 use SELECTEDVALUE() and I can't see anything else I could use.  I understand that this would be complex as the condition could be equals, not equals, etc. 

This isn't my example, but a trivial example might be a web site where someone enters their search term "tomato" which is passed as a filter to the URL and the report would not contain any tomato data so could show a message "sorry, tomato not found".  In my case I can't ensure that the value passed is always present in the data.

Many thanks.

  • 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.

1 Reply

  • 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.