Forum Discussion
in selector json what is the 't' attribute
- 7 years ago
Hi rdegr,
I had a similar request andwas able to solve it in the following was:
1. I create an array of custom identities, in this case it uses the category as text, but that can be changed to SQExprBuilder.number if needed.
let categoryIdentities = categories.map((category) => { let sqlExpr = powerbi["data"].SQExprBuilder.equal(dataView.metadata.columns[0].expr, powerbi["data"].SQExprBuilder.text(category)); return powerbi["data"].createDataViewScopeIdentity(sqlExpr); });
# ref: https://github.com/liprec/powerbi-boxWhiskerChart/blob/89179879a7209b030245fd05c317eee2034db394/src/boxWhiskerChart.ts#L2602. When I loop thru the individual catagories (=i variable)I use the following code to create the correct SelectionId identifier:
let selectionId = new SelectionId({ data: [ categoryIdentities[i] ] }, false); # ref: https://github.com/liprec/powerbi-boxWhiskerChart/blob/89179879a7209b030245fd05c317eee2034db394/src/boxWhiskerChart.ts#L282I added links to my solution for more reference and hope this can also work for your visual.
-JP
As far as I know you can add extra columns to the `sqlExpr` variable and combine them with `powerbi["data"].SQExprBuilder.and` method.
There is no need to construct this kind of filters/selectors by yourself as all the needed methods of `SQExprBuiler` are exposed to be used with a Custom Visual. Take a look at the repository of the old Power BI visuals: https://github.com/avontd2868/PowerBI-visuals/tree/master/src/Clients/Data/semanticQuery for more details.
-JP
Please note SQExprBuilder is not documented as official API. It might be removed or changed without any notification.
If you need some specific API please send us details to [email protected]
Otherwise, you might get unexpected breaks.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- v-viig7 years ago
Community Champion
Got you. API 2.1.0 removed use internal interfaces to make API lighter.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- rdegr7 years ago
Helper I
Thank you, that is useful to know. I'm on 1.5 currently as some samples I looked at early on didn't work with 2.x. This is for a single app of ours, we don't plan to try to publish it publicly.