Forum Discussion

JSJB's avatar
JSJB
Helper I
3 years ago
Solved

Add a data field that does NOT impact visual

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 🙂

  • 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.

6 Replies

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

    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

    • JSJB's avatar
      JSJB
      Helper I

      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

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

        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