Forum Discussion

ysapiyev's avatar
ysapiyev
Responsive Resident
8 years ago
Solved

How to alter capabilities.json to have 4 inputs for values?

hi,

 

I am creating custom visual, and I'm new in power bi. I need to be able to enter 1 category and 4 values in capabilities.json in categorical data mapping. how it can be done?

  • v-viig's avatar
    v-viig
    8 years ago

     

    {
        "dataRoles": [
            {
                "displayName": "Category",
                "name": "Category",
                "kind": "Grouping"
            },
            {
                "displayName": "Values1",
                "name": "Values1",
                "kind": "Measure"
            },
            {
                "displayName": "Values2",
                "name": "Values2",
                "kind": "Measure"
            },
            {
                "displayName": "Values3",
                "name": "Values3",
                "kind": "Measure"
            },
            {
                "displayName": "Values4",
                "name": "Values4",
                "kind": "Measure"
            }
        ],
        "dataViewMappings": [
            {
                "categorical": {
                    "categories": {
                        "for": {
                            "in": "Category"
                        }
                    },
                    "values": {
                        "select": [
                            {
                                "for": {
                                    "in": "Values1"
                                }
                            },
                            {
                                "for": {
                                    "in": "Values2"
                                }
                            },
                            {
                                "for": {
                                    "in": "Values3"
                                }
                            },
                            {
                                "for": {
                                    "in": "Values4"
                                }
                            }
                        ]
                    }
                }
            }
        ]
    }

     

    Ignat Vilesov,

    Software Engineer

     

    Microsoft Power BI Custom Visuals

    [email protected]

     

8 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    why don't you simply use Table instead of categorical ? otherwise I think what you are looking for is serie.

    • v-viig's avatar
      v-viig
      Community Champion

       

      {
          "dataRoles": [
              {
                  "displayName": "Category",
                  "name": "Category",
                  "kind": "Grouping"
              },
              {
                  "displayName": "Values1",
                  "name": "Values1",
                  "kind": "Measure"
              },
              {
                  "displayName": "Values2",
                  "name": "Values2",
                  "kind": "Measure"
              },
              {
                  "displayName": "Values3",
                  "name": "Values3",
                  "kind": "Measure"
              },
              {
                  "displayName": "Values4",
                  "name": "Values4",
                  "kind": "Measure"
              }
          ],
          "dataViewMappings": [
              {
                  "categorical": {
                      "categories": {
                          "for": {
                              "in": "Category"
                          }
                      },
                      "values": {
                          "select": [
                              {
                                  "for": {
                                      "in": "Values1"
                                  }
                              },
                              {
                                  "for": {
                                      "in": "Values2"
                                  }
                              },
                              {
                                  "for": {
                                      "in": "Values3"
                                  }
                              },
                              {
                                  "for": {
                                      "in": "Values4"
                                  }
                              }
                          ]
                      }
                  }
              }
          ]
      }

       

      Ignat Vilesov,

      Software Engineer

       

      Microsoft Power BI Custom Visuals

      [email protected]

       

      • Maikeru's avatar
        Maikeru
        Helper II

        v-viig

         

        I am beginning to design custom visuals and am interested by this data scheme.

         

        Once the capabilities.json is set, how would you extract each Value 1, 2, 3, 4 into the visual.ts file?

        I understand that the dataViews method is able to fetch user data but I can't figure out the correct syntax to pick each specific node.

         

        Sorry for this newbie question. I am also just starting with TS.

         

        Thank you in advance for your guidance.

         

        Best regards

         

        Michael