Forum Discussion

KennethWang's avatar
KennethWang
Frequent Visitor
7 years ago

SelectionIdBuilder - For consolidated data categories

Hi, I have a very specific use case for PowerBI Custom Visuals.  I managed to convert and reference many of the existing examples to what I need, but I am having a problem understanding how selection works, or works in my use case.

 

Say, for example, if I have a dataset (inventory log)

USER IDITEMS
0001Book
0001Ruler
0002Eraser
0001Bag
0002Book
0003Book
0003Eraser

 

In my visual bar chart (d3), I want to show

 

Inventory Group 1 (Book+Ruler+Bag) => Count = 1

Inventory Group 2 (Book+Eraser) => Count = 2 

 

So as it is, I'll have to pre-process the data into an array (I used associative array), which is fine.

 

The problem I have is on selection. I'll like to be able to click on "Inventory Group 1" and have it selected/filtered across other visuals (showing User 0001, and Book, Ruler, Bag) and "Inventory Group 2" to show (User 0002 and User 0003, and Book, Eraser) in other visuals.

 

I used something like

 

identity: host.createSelectionIdBuilder()
                    .withCategory(categorical.User, 1)
                    .withMeasure(_CustomArrayUsers[0])

Which is filtering only the first record. When I clicked "Inventory Group 1", it shows User 0001 BUT only "Book" row got highlighted (in the other visual). When I clicked "Inventory Group 2", it shows (only) User 0002 and only "Eraser",

 

Is this type of selection supported in PowerBi? Thanks.

 

Regards,

 

Kenneth

 

 

 

 

3 Replies

  • dm-p's avatar
    dm-p
    Super User

    Hi KennethWang,

    It's possible the .withMeasure() is the culprit but it's quite hard to verify without knowing the structure of the _CustomArrayUsers[0] entry you're feeding into it. This should be a string representation of the measure name from your field's metadata. It would also be worth taking a look at the category processing too, to make sure that it's passing in the correct values. If you're able to share your code then that would be a great help in helping you out. If you want to share privately, feel free to PM me and I'll try to free up some time to have a look for you.

    Also: consider checking the version of powerbi-visuals-tools you're using - we found out there is definitely something funky with Selection IDs in 2.1.0 the other day and this may be compounding the problem.

    Regards,

    Daniel

    • KennethWang's avatar
      KennethWang
      Frequent Visitor

      dm-p Thank you! I was using 2.6.1. 

       

      I think I figured out what I need using BasicFilter. It worked for me but I am confused between SelectionManager vs Basic/Advanced Filters.

       

      Also, api 2.6.1 required a few tweaks from examples to make things work. 

      • dm-p's avatar
        dm-p
        Super User

        Yes, if you're on 2.6 + of the API / 3.x of the SDK then the doc is woefully out of date, but sounds like you're rocking, which is the important thing here! Glad you're sorted :)