Forum Discussion
set value field in report powerbi by custom visual
- 8 years ago
This code snippet is going to address the issue:
let selectionIds = []; selectionIds.push(host.createSelectionIdBuilder() .withCategory(categorical.categories[0], 0) .createSelectionId() ); selectionIds.push(host.createSelectionIdBuilder() .withCategory(categorical.categories[1], 0) .createSelectionId() ); selectionIds.push(host.createSelectionIdBuilder() .withCategory(categorical.categories[0], 1) .createSelectionId() ); selectionIds.push(host.createSelectionIdBuilder() .withCategory(categorical.categories[1], 1) .createSelectionId() ); selectionIds.forEach((selectionId) => { this.selectionManager.select(selectionId, true) });Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
Do you want to imlement a Slicer to filter data out?
If so, please use JSON Filter.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
I just want to implement the same behavior as SampleSlicer has in the bottom part: show list of possible values, where some of them can be checked and all unchecked filtered out.
Is JSON filter suitable for this task? I though it is primarily intended to be used for range filters and I need to use something different that allows to select discrete values..
- v-viig7 years agoCommunity Champion
Yes, JSON Filter can be used to filter data. In your case you shoould use BasicFilter.
You can find details in powerbi-models documentation.
const basicFilter: models.IBasicFilter = { target: { table: "Products", column: "Version" }, operator: "In", values: [ 1, 2, 3, 4 ] };
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- seregindv7 years agoFrequent Visitor
What confuses me is that data I need to filter contains 5 string (and some more numeric) columns and 25-30000 rows. Primary key is those 5 string columns and user can select up to 15000 rows to display. And If I choose to use JSON Filter, I would probably need to use IAdvancedFilter with 5 'in' conditions each of which 'values' field contains up to 15000 elements string array. Would it be the best way to filter from performance standpoint?
Upd: I went ahead and attempted to implemented advanced filter with 5 'in' conditions and figured out that it doesn't support this type of condition. And basic filter can filter only one category..
Upd2: And advanced filter as well
- v-viig7 years agoCommunity Champion
Correct. There's no way to filter by two or more columns at the same time.
Such a feature is landing soon (most likey by end of this year).
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- seregindv7 years agoFrequent Visitor
No way. I can't wait that long. HierarchySlicer can already do this and I probably can filter in the same way it does. How does it do this?
- v-viig7 years agoCommunity Champion
Hierarchy Slicer is on legacy API so far but it will be converted to PBI Custom Visuals API soon once multi column filtering API is released.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- dakdgdl3 years agoHelper I
Hi v-viig
I tried cross-filte by cross-select as below.
--------------------------
let rowSelection: ISelectionId = this.visualHost.createSelectionIdBuilder().withTable(this.dataView.table, rowIndex).createSelectionId();await this.selectionManager.select(rowSelection, true).then(result => {console.log(result);});-------------------------------result is just like below-------------------------- [t]
- 0: t
- dataMap:
- {"identityIndex":0}: [{…}]
- [[Prototype]]: Object
- deepestNodeLevelInPath: -1
- key: "{\"{\\\"identityIndex\\\":0}\":[{\"identityIndex\":0}]}[]"
- measures: []
- nodeIsCollapsed: null
- [[Prototype]]: Object
- length: 1
- [[Prototype]]: Array(0)--------------------------------
But this didn't cross-select the passed selectionID row in other visuals of the page.What could be the reason. Any specific config setting in tsconfig, capabilities.json or webpack.configPlease advise.Thanks in advance,
Lasantha