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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
julip
New Member

Data bound settings/objects with Table DataViewMapping

I don't find a way to implement dataBound settings on for table dataViewMapping. My data is simplified and changed to a table of fruits saled in countries:

 

Capabilities:

 

 

{
    "privileges": [],
    "objects": {
      "dataItem": {
        "properties": {
          "color": {
            "type": {
              "fill": {
                "solid": {
                  "color": true
                }
              }
            }
          }
        }
      }
    },
    "dataRoles": [
      {
        "displayName": "Country",
        "name": "country",
        "kind": "Grouping"
      },
      {
        "displayName": "Fruit",
        "name": "fruit",
        "kind": "Grouping"
      },
      {
        "displayName": "Saled pieces",
        "name": "saleCount",
        "kind": "Measure"
      }
    ],
    "dataViewMappings": [
      {
        "table": {
          "rows": {
            "select": [
              {
                "for": {
                  "in": "country"
                }
              },
              {
                "for": {
                  "in": "fruit"
                }
              },
              {
                "for": {
                  "in": "saleCount"
                }
              }
            ]
          }
        }
      }
    ],
    "sorting": {
      "implicit": {
        "clauses": []
      }
    }
  }

 

visual.ts

 

 

class MyVisual {
  public getFormattingModel(): powerbi.visuals.FormattingModel {
    return {
      cards: [
        {
          displayName: "Fruit Card",
          uid: "card",
          groups: [
            this.data
              .getFruitTypes()
              .map(({ fruit, fruitTypeSelectionId, color }) => ({
                uid: fruit,
                displayName: fruit,
                slices: [
                  {
                    uid: "sliceid",
                    displayName: "Color",
                    control: {
                      type: powerbi.visuals.FormattingComponent.ColorPicker,
                      properties: {
                        descriptor: {
                          objectName: "dataItem",
                          propertyName: "color",
                          altConstantValueSelector:
                            fruitTypeSelectionId.getSelector(),
                          selector: fruitTypeSelectionId.getSelector(),
                        },
                        value: { value: color },
                      },
                    },
                  },
                ],
              })),
          ],
        },
      ],
    };
  }
}

 

 

and my DataViewModel sth. like this

export class Data {
  static fromDataView = (dataView: DataView, host: IVisualHost) => {
    const fruitTypes = [];
    dataView.table.rows.forEach((row) => {
      if (fruitTypeDoesNotExist(row, fruitTypes)) {
        fruitTypes.push({
          color:
            someSelectFunctionToRetrieveTheFruitColorFromDataView(dataView),
          fruitTypeSelectionId: host
            .createSelectionIdBuilder()
            .withMeasure(selectFruitName(row))
            .createSelectionId(),
          fruit: selectFruitName(row),
        });
      }
    });
    return new Data(fruitTypes /* ... */);
  };
}

 I dont't find any documentation on how to choose the selector and on how to create selectionIds for table DataViewMappings. 

 

Can you please help?

0 REPLIES 0

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.

Top Solution Authors