Search code examples
powerbipowerbi-custom-visuals

How to configure a Power BI Visual to display string values in a matrix?


I'm new to Power BI Visual development, and struggling to configure my data roles and data view mappings. I want to create a roadmap visual that has columns for each quarter across a time span, rows for each team that is working on the project, and in the cells showing the name of the deliverables that are scheduled for the various quarters. There can be multiple values in the same cell, and the same deliverable might appear with multiple dates to show that incremental deployments are planned.

(Apologies for the table formatting, during the edit it shows up correctly, but once I post it just shows up as text...)

My input data is something like this:
| Team | Deliverable | Date | other columns for further formatting... |
| ------ | ------------- | ------- | --------------------------------------- |
| Team 1 | Deliverable 1 | 2024 Q3 | |
| Team 1 | Deliverable 1 | 2025 Q2 | |
| Team 1 | Deliverable 2 | 2024 Q3 | |
| Team 1 | Deliverable 3 | 2024 Q4 | |
| Team 2 | Deliverable 4 | 2024 Q3 | |
| Team 2 | Deliverable 4 | 2024 Q4 | |

What I want to display is something like this:
| Team | 2024 Q3 | 2024 Q4 | 2025 Q1 | 2025 Q2 |
| ---- | ------- | ------- | ------- | ------- |
| Team 1 | Deliverable 1, Deliverable 2 | Deliverable 3 | | Deliverable 1 |
| Team 2 | Deliverable 4 | Deliverable 4 | | |

In my capabilities.json file I tried using categorical, table, and matrix dataViewMappings, but my problem is that Power BI expects a "measure" kind for values, which can only be numerical.

Any pointers would be very much appreciated!


Solution

  • Wanted to post my solution hoping it can help others. Indeed if we define a Measure kind for a data role, then it'll only accept either a numerical value, or will pick the first or last string that maps to the groupings.

    To get around this, the solution is to define all the data roles with kind as Grouping.

    In this case, in the dataView object, under dataView.Categorical, we'll only see a categories array, and no values array. However, this should not be a problem, as we iterate through the data we can simply pick the relevant values from the categories arrays.

    With this we can display multiple deliverables in a single cell, and we can apply formatting to each, individually.