问题
I am trying to use TupleFilter in powerbi-client, since I need to filter data based on two different columns with OR statement between them (2 different columns in the same table or may be in 2 different ones), check this question out.
As I read in this docs, tuple filter can do this.
However, when I tried to use it with report.setFilters(filters)
function, I got this error from setFilters function: "undefined property is invalid".
Moreover, I didn't find the function used in the above docs in powerbi-client:
visualHost.applyJsonFilter(filter, "general", "filter", FilterAction.merge)
So, I just tried setFilters(filters).
Getting deeper in the filters docs, I found this:
Report level filter supports the following types: IBasicFilter | IAdvancedFilter | IRelativeDateFilter.
Page level filter supports the following types: IBasicFilter | IAdvancedFilter | IRelativeDateFilter.
Visual level filter supports the following types: IBasicFilter | IAdvancedFilter | IRelativeDateFilter | ITopNFilter | IIncludeExcludeFilter.
So, what I couldn't understand, how to use Tuple Filters if none of the above filter levels support it!
回答1:
Tuple filter is not supported for embedding
You read correctly, TupleFilter is not supported in any filter level. It's an API used by Power BI visuals - so it can be used to create custom slicers (such as HierarchySlicer - it may solve your issue btw). Currently however, tuple filters aren't supported for Power BI filters at all, so can't be used with powerbi-client - which deals with embedding a Power BI "element" (report, dashboard, visual etc.) inside a web page or application.
Note that tuple filter support for powerbi-client may be added in the future.
Full disclosure: I'm a Microsoft employee, working in one of Power BI's development teams. No affiliation with HierarchySlicer visual.
来源:https://stackoverflow.com/questions/59181883/powerbi-how-to-use-tuplefilter-with-powerbi-client