Reports based on a dynamically filtered slice (as per Dashboard)

I have a dashboard view based on a dynamically filtered slice of my main table, which will display records based on calculations relating to several filter fields. Works perfectly for both single and multiple choices and combinations of each.

If I try to base a report off this filtered slice, a blank table is returned. This is the same behaviour as if I try to view the data of the filtered slice in the Data menu - it seems like the filters are only applied/calculated when the slice is โ€˜calledโ€™ in a view.

My question is how can I set up a filtered report based off a slice - I can get around it by making new slices with all the possible permutations and combinations of what the filter fields are but then I end up with 30+ slices and the same number of reports and templates to edit etc. and it gets very messy to manage.

Solved Solved
0 6 742
1 ACCEPTED SOLUTION

Hereโ€™s your expression, reformatted to my taste:

AND(
  IF(
    ISBLANK(
      IN(
        [Hospital],
        Procedure Filter[fHospital]
      )
    ),
    TRUE,
    IN(
      [Hospital],
      Procedure Filter[fHospital]
    )
  ),
  IF(
    ISBLANK(
      IN(
        [_Year],
        Procedure Filter[fYear]
      )
    ),
    TRUE,
    IN(
      [_Year],
      Procedure Filter[fYear]
    )
  )
)

Note that these are nonsensical:

ISBLANK(
  IN(
    [Hospital],
    Procedure Filter[fHospital]
  )
),

and:

ISBLANK(
  IN(
    [_Year],
    Procedure Filter[fYear]
  )
),

The result of IN() will never be blank: it will be either TRUE or FALSE.

Typically, when one has a filter table, the goal is to treat an empty filter parameter as โ€œmatch anyโ€, but if it has a value, to match that value. An expression that should achieve that is:

AND(
  OR(
    ISBLANK(Procedure Filter[fHospital]),
    IN([Hospital], Procedure Filter[fHospital])
  ),
  OR(
    ISBLANK(Procedure Filter[fYear]),
    IN([_Year], Procedure Filter[fYear])
  )
)

See also:

View solution in original post

6 REPLIES 6

โ€œrelating to several filter fieldsโ€

Where in the data model are these fields located? I think your report doesnโ€™t have knowledge of their existing one way or another.

If you were to create a โ€œglobalโ€ table with only a single row of data, and then reference fields in it using Any(GlobalTable[aFilterField]), I bet your report would work.

The filter fields are located in a seperate Procedure Filters table so I can have different filters for different users. I currently have a slice based on two filter fields: Year and Hospital and these are all enum lists as they can have one or many values depending on what the user wants to see pulled out of the main data table.

I then use a calculation with AND() and multiple IF() and IN() to select the rows I want the slice to display on a Dashboard View:

AND(
IF(ISBLANK(IN([Hospital], Procedure Filter[fHospital])), TRUE, IN([Hospital], Procedure Filter[fHospital])),
IF(ISBLANK(IN([_Year], Procedure Filter[fYear])), TRUE , IN([_Year], Procedure Filter[fYear]))
)

So you are suggesting I make a virtual column in the main data table which references the filter field values from the Global(in my case Procedure Filter table) and then base the report slice off rows that have data in that field - indicating the have a valid value from the filter table - perhaps a True/False type expression like IF(IN([Hospital], Procedure Filter[fHospital]), TRUE, FALSE) ?

I really appreciate your thoughts and help - Iโ€™m new to this sort of expression building.

Hereโ€™s your expression, reformatted to my taste:

AND(
  IF(
    ISBLANK(
      IN(
        [Hospital],
        Procedure Filter[fHospital]
      )
    ),
    TRUE,
    IN(
      [Hospital],
      Procedure Filter[fHospital]
    )
  ),
  IF(
    ISBLANK(
      IN(
        [_Year],
        Procedure Filter[fYear]
      )
    ),
    TRUE,
    IN(
      [_Year],
      Procedure Filter[fYear]
    )
  )
)

Note that these are nonsensical:

ISBLANK(
  IN(
    [Hospital],
    Procedure Filter[fHospital]
  )
),

and:

ISBLANK(
  IN(
    [_Year],
    Procedure Filter[fYear]
  )
),

The result of IN() will never be blank: it will be either TRUE or FALSE.

Typically, when one has a filter table, the goal is to treat an empty filter parameter as โ€œmatch anyโ€, but if it has a value, to match that value. An expression that should achieve that is:

AND(
  OR(
    ISBLANK(Procedure Filter[fHospital]),
    IN([Hospital], Procedure Filter[fHospital])
  ),
  OR(
    ISBLANK(Procedure Filter[fYear]),
    IN([_Year], Procedure Filter[fYear])
  )
)

See also:

Steve
Platinum 4
Platinum 4

Note that reports are run as the app owner, not as any other user of the app. If your filters are user- or device-specific, the report will not use it (unless the user happens to be the app owner).

Thanks Steve Iโ€™ve made sure user = app owner at this stage.

From Tyโ€™s suggestion I have made a column to reference the values in the global filter field, but for some reason my IN() expression is returning FALSE even if the value is present in the LIST.

IN([Hospital], Procedure Filter[fHospital])

Is there something simple Iโ€™m missing here ? Clearly the value of [Hospital] is present in the List so should it not return Y (true) ? If I can get this working, then the reporting part is fine.

Thanks for any advice.

Got it working. Thanks very much for your time and detailed explanations - I think I finally understand the filtering logic now !

Top Labels in this Space