The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello,
I need to implement a sort of "choices" menu for inputting data in a Power BI custom visual. All of the functionality is implemented, by which I mean generating the dropdown, populating it with options, and adding a value when a selected option is pressed. The only thing I need is to change the "data source" for the dropdown. Currently, the values are hard-coded or supplied by the formatting settings. I need the data source for the dropdown to be a dimension supplied by a data field.
However, when I add a data field both as measure or grouping, any supplied dimension impacts the "meat" of the visual (a matrix). I have looked around but I cannot find any method of simply adding a data field without the supplied data impacting the rest of the visual. By "impact the visual", I mean that the data in the field is automatically added to the matrix (despite me not specifying this anywhere).
In essence, my question is: How can I add data to a custom visual that does not impact the visual itself, but would purely be for "back-end" or "developmental" purposes?
For further clarification, in its simplest state the data could just be a small list/table of data points, e.g. values: [100, 200, 500, 1000]
Thank you for your help 🙂
Solved! Go to Solution.
I think that with measures, you only get the ability to choose the actual measure at the top-level and not any specific values, as this is how selectors work. I would anticipate that you would get the same functionality as the core maxtrix visual's properties, e.g. if I have two measures in my matrix data view I get the following in the properties pane:
I can't do anything with the measure values here, just configure properties at a measure level.
With the categorical mapping you can get distinct group or series values, but I don't think that the matrix mapping has similar levels of aggregation when it comes to selectors.
I'm of the opinion that you're going to have to ask the custom visuals team for the functionality you're looking for, as this still would involve adding a secondary dataset to the visual, which is currently not possible.
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)
Hi @JSJB,
Because visuals only get one query, adding disconnected data will have an effect on your visual's data view. If you cannot match the desired granularity of this query by adding non-related data and remove it when processing into your viewmodel, one option would be to somehow post-process the data view to split out the components and recreate your desired datasets in your viewmodel processing. This is far from ideal, as you cannot guarantee how a user's measures will behave and you will not be able to guarantee the aggregation (or internal logic) as this is not exposed to the data view.
The only other option based on current functionality would be to create a scalar measure of your dimension data that is flattened (e.g. through CONCATENATEX or similar) and create a conditional formatting property for it that the user can add themselves. You will need to deseralise this in your visual's code and render what you want from it.
There's currently no other way to get disconnected data into the data view, so if the conditional formatting approach can work, you'll need to ensure that you rusers understand this requirement in order to use your visual correctly.
Regards,
Daniel
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)
Hi @dm-p ,
First of all, I want to thank you many times over for your efforts here. You always deliver well written and researched answers and it is extremely helpful in so many ways.
Second, is it truly not possible to get any form of data in a "secondary query"? E.g. the field picker formatting setting? I found it yesterday while researching this issue and tried setting one up, as you can see here.
My hope was that this would allow for some sort of querying of data that would not necessarily impact the visual. As these would be captured in the option.dataview.metadata.objects rather than option.dataview.matrix. I am used to the formatting settings not impacting visuals in any way unless I program it to. I thought perhaps this would be similar - but I may be mistaken?
As always, thank you for your diligent help.
- Jonas
Hi @JSJB, and glad you've found my help useful! I really appreciate it.
The field dropdown is used to assign properties to a measure or column based on selection ID, much like for the core visuals when properties will swap out based on what you choose in this dropdown. The changes you make will place corresponding objects in the data view based on the selection ID of the entry. Selection IDs must pertain to existing measures or columns in the data view, so unfortunately it doesn't provide any additional functionality for querying the data mode (just pushing things to the metadata).
To the best of my knowledge if you'r eusing the matrix data view mapping you would need to use selection IDs at the cell level, so you'd likely get a property entry for each (and in which case, it's probably better to use a dedicated data role and measure, as it would resolve to the same grain. Also, it looks like conditional formatting properties aren't supported for the matrix data view, which is a great shame (but probably for the same reasons).
Regards,
Daniel
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)
The field dropdown is used to assign properties to a measure or column based on selection ID, much like for the core visuals when properties will swap out based on what you choose in this dropdown. The changes you make will place corresponding objects in the data view based on the selection ID of the entry. Selection IDs must pertain to existing measures or columns in the data view, so unfortunately it doesn't provide any additional functionality for querying the data mode (just pushing things to the metadata).
Thank you for your helpful answer (again). Just one final question:
Based on your description of the formatting settings field picker, it may actually be exactly what I'm looking for. Specifically, the custom visual shows a matrix table. Part of our core feature is that users can edit the data directly in the table. It has been a requested feature that users could configure a drop down menu that appears when a user clicks a cell, with some default value choices (helpful in cases where end-users should only have limited choices, or in cases of often repeated inputs). I am adding a picture to illustrate this:
We imagined this would happen on a per-measure level. So in this case, the measure is quantity and the choices would then be different typical quantities. If the field picker "hooks into" a specific measure, would I be able to use it to allow users to add their own data fields for each measure they want to have a dropdown, thereby achieving what I want?
I apologize for the lengthy question and talk. I really have looked around all over for documentation or use-cases of the field picker (with code), but I simply could not find any.
Best regards
I think that with measures, you only get the ability to choose the actual measure at the top-level and not any specific values, as this is how selectors work. I would anticipate that you would get the same functionality as the core maxtrix visual's properties, e.g. if I have two measures in my matrix data view I get the following in the properties pane:
I can't do anything with the measure values here, just configure properties at a measure level.
With the categorical mapping you can get distinct group or series values, but I don't think that the matrix mapping has similar levels of aggregation when it comes to selectors.
I'm of the opinion that you're going to have to ask the custom visuals team for the functionality you're looking for, as this still would involve adding a secondary dataset to the visual, which is currently not possible.
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)
Thanks for your help (again).
We have gone with your workaround of ConcatenateX. While this complicates things slightly for users (and ourselves, given the deserialization and "matching" of data), it seems this is the easiest solution for all parties. We have a rudimentary solution running now.
Thank you for your help. It has been invaluable.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
3 | |
3 | |
3 | |
1 | |
1 |
User | Count |
---|---|
8 | |
5 | |
2 | |
2 | |
1 |