Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Custom Visual - How to get selected items from a dimension?

We have a simple custom visual which has some dimensions as a categorical type.


With options.dataViews[0] etc. we get all of the possible values. But what we need is the user selected values instead all of them. Like when you're having country and products - if the users selects only a country we should get no value for products as no element is selected (no matter if values are possible!). Any example for this?

 

Got a look at the selectionManager but had to give up due to...lacking documentation(?). Using the latest API version / pbiviz.

 

3 REPLIES 3
dm-p
Super User
Super User

Hi @Anonymous,

It's not entirely clear from your description what the actual problem is. The dataView contains the currently selected items in the report, for example from a slicer or other visual. If your visual's dataView contains all data then it implies there are no particular filters currently applied to it. Depending on your use case, it might be how your dataRoles are configured, or you might have to apply filtering or highlighting to do what you want with the data passed into the dataView.

If you are able to provide some code or a more detailed description of your expected outcomes then I might be able to provide more targeted help. Failing that, you can try posting in the Custom Visuals Development Discussion forum and the dev team can help (they only monitor that forum for questions).

Regards,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Anonymous
Not applicable

Hi @dm-p ,

 

Let me try to explain it by an example:

 

ProductCountry
ProdAItaly
ProdBGermany
ProdCGermany

 

I'm passing both dimensions to my custom visual. I need to distinguish between "has data/connection" and "isUserSelected". For example, user selects Italy - custom visual is getting ProdA. BUT: This is not user selected, it just has a connection to Italy. I need only Italy. IF the user now selects also ProdA & Italy, I should get ProdA and Italy as both are selected. It's fine to get all possible elements, but I need to check somehow if the element is really user selected or just with data.

 

Hope this helps a bit? 

 

(and sorry for the wrong section in the forum, didnt saw it yesterday 😞 Maybe some mod could move it to the custom visual dev. place 🙂 )

Hi @Anonymous,

Thanks for clarifying - I'm still not 100% sure, but it sounds like you're after the ability to have partial highlighting support on your visual (where all data is passed, but the selected values are also indicated)? If so, you need to add supportsHighlight: true to your capabilities.json.

The previous link references a follow-up article on coding the support for highlights, which documents what you'll see in your dataView after enabling the capability. You will need to compare the entries from the highlights array with those in the values array to determine which data points are affected and write code accordingly to dim/hide (or however you want to represent visually) the visual representation of these data points.

I hope that this gets you moving in the right direction. Good luck!

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.