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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors