<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Custom Color Formatting for Groups in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Color-Formatting-for-Groups/m-p/4894436#M64038</link>
    <description>&lt;P&gt;I came across the very same situation. However it was one of those 'it works but I don't know how situation.&lt;BR /&gt;Therefore this extra comment:&lt;BR /&gt;For me the using the withSeries(values, group) worked indeed only after using .grouped(). However the &lt;U&gt;values didn't appear in my DataView when I exported it&lt;/U&gt;. I had to call the '.grouped()' function again to see the actual values. (JSON.stringify just DROPPED the grouped() result but that didn't mean it wasn't there)&lt;BR /&gt;A LOT of headscratches on this one.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Dec 2025 15:51:03 GMT</pubDate>
    <dc:creator>matthias_vc</dc:creator>
    <dc:date>2025-12-05T15:51:03Z</dc:date>
    <item>
      <title>Custom Color Formatting for Groups</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Color-Formatting-for-Groups/m-p/2764204#M38613</link>
      <description>&lt;P&gt;Good day!&lt;BR /&gt;&lt;BR /&gt;I am trying to add custom coloring to my visual, but I have trouble implementing this with grouping.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Situation:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The data consists of multiple projects, which in turn have multiple milestones.&amp;nbsp;Basically it's a line graph, with a line for each milestone. The user has two options:&lt;BR /&gt;1) Draw all milestones from &lt;STRONG&gt;only one&lt;/STRONG&gt; project. The user can change the color of each milestone. (This already works)&lt;/P&gt;&lt;P&gt;2) Draw all milestones from &lt;STRONG&gt;all&lt;/STRONG&gt; projects inside one graph. In this situation all milestones within one project have the same color (works). The user should be able to change the color of a project with custom formatting. (&lt;STRONG&gt;This doesn't work&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;snippet from capabilities.json:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  "dataRoles": [
    {
      "displayName": "Date",
      "name": "date",
      "kind": "Grouping"
    },
    {
      "displayName": "Milestones",
      "name": "milestones",
      "kind": "Measure"
    },
    {
      "displayName": "Project Name",
      "name": "project",
      "kind": "Grouping"
    }
  ],
  "dataViewMappings": [
    {
      "categorical": {
        "categories": {
          "for": {
            "in": "date"
          }
        },
        "values": {
          "group": {
            "by": "project",
            "select": [
              {
                "for": {
                  "in": "milestones"
                }
              }
            ]
          }
        }
      }
    }
  ],&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;snippet from&amp;nbsp;&lt;SPAN&gt;enumerateObjectInstances function:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;objectEnumeration.push({
  objectName: objectName,
  displayName: project.name,
  properties: {
    lineColor: ms.colorLine
  },
  propertyInstanceKind: {
    fill: VisualEnumerationInstanceKinds.ConstantOrRule
  },
  selector: selectionId.getSelector()
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Problem&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;I can't implement Situation 2). I think the problem is the selector. Among others I tried the following:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;A) selectionId = host.createSelectionIdBuilder().withCategory(categories, i).createSelectionId();

B) selectionId = host.createSelectionIdBuilder().withMeasure(ms.source.groupName.toString()).createSelectionId();

C) selector = {metadata: column.queryName};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A) The color is saved in categories. However, this only works if there are equal or more categories than groups (not guaranteed).&amp;nbsp;This&amp;nbsp;was just a workaround by me trying to understand how selectors work. I was hoping for a better solution than this.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sflo_1-1663068274212.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/782650i4D160174433CCA74/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sflo_1-1663068274212.png" alt="sflo_1-1663068274212.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;B) This doesn't work. Changing a color doesn't seem to be saved anywhere in dataViews&lt;/P&gt;&lt;P&gt;After changing a color . The selector looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
    "metadata": "Name of the Group/Project"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;C) Using this selector changes the color of the milestones (independ of project). E. g. all milestone1 of all projects will be green, all milestone2 will be red...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody have an idea how I can implement custom formatting of the milestones based on the project? Maybe I also have to change the data model?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for any help!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 11:28:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Color-Formatting-for-Groups/m-p/2764204#M38613</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-13T11:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Color Formatting for Groups</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Color-Formatting-for-Groups/m-p/2765721#M38630</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;@Anonymous&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;According to your description, I don't think your requirement can be achieved based on the code in the custom color formatting &lt;SPAN&gt;groups&lt;/SPAN&gt;. They should be more suitable to use condition formatting in visuals based on Dax expressions.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-conditional-table-formatting#color-based-on-a-calculation" target="_blank"&gt;Apply conditional table formatting in Power BI - Power BI | Microsoft Docs&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;You can use dax expressions to look up correspond records based on current row context and apply color code.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;BTW, they can be also pre-declared in a table then you can use DAX expression to load these color code settings from that table.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 01:59:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Color-Formatting-for-Groups/m-p/2765721#M38630</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-14T01:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Color Formatting for Groups</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Color-Formatting-for-Groups/m-p/3052387#M40976</link>
      <description>&lt;P&gt;Hello Internet,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I managed to make it work. It was rather simple:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Basic example&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Get values grouped&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;const groups = dataViews[0].categorical.values.grouped()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Set selectionId for each group:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;values = dataViews[0].categorical.values;
groups.forEach(group =&amp;gt; {
  selectionIdGroup = host.createSelectionIdBuilder().withSeries(values, group).createSelectionId()
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Set selectionId for each measure:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;selectionIdMeasure = host.createSelectionIdBuilder().withMeasure(dataViewColumn.source.queryName).createSelectionId()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. You can then access these in formatting pane:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let groupColor: powerbi.visuals.FormattingGroup = {
    displayName: "Colors",
    uid: "colors",
    slices: {
        displayName: group.name,
        uid: "colors_" + group.name,
        control: {
            type: powerbi.visuals.FormattingComponent.ColorPicker,
            properties: {
                descriptor: {
                    objectName: "series",
                    propertyName: "line",
                    selector: group.selectionId.getSelector()
                },
                value: { value: group.colorLine },
            }
        }
    }
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps anyone &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 10:45:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Color-Formatting-for-Groups/m-p/3052387#M40976</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-01-31T10:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Color Formatting for Groups</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Color-Formatting-for-Groups/m-p/3986082#M53311</link>
      <description>&lt;P&gt;I'm struggling with similar issue but not able to get it work even if I try to do exactly same as you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;        const groups = dv.categorical.values.grouped();
        const values = dv.categorical.values;

        groups.forEach(group =&amp;gt; {
            const selectionIdSeries = host.createSelectionIdBuilder().withSeries(values, group).createSelectionId();
            console.log(selectionIdSeries);
        });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;This logs me:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "deepestNodeLevelInPath": -1,
    "measures": [],
    "dataMap": null,
    "nodeIsCollapsed": null,
    "nodeIndexes": [],
    "key": "null[]"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why I get null? What do you get if console log your selection id?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 12:38:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Color-Formatting-for-Groups/m-p/3986082#M53311</guid>
      <dc:creator>Vil</dc:creator>
      <dc:date>2024-06-11T12:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Color Formatting for Groups</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Color-Formatting-for-Groups/m-p/4894436#M64038</link>
      <description>&lt;P&gt;I came across the very same situation. However it was one of those 'it works but I don't know how situation.&lt;BR /&gt;Therefore this extra comment:&lt;BR /&gt;For me the using the withSeries(values, group) worked indeed only after using .grouped(). However the &lt;U&gt;values didn't appear in my DataView when I exported it&lt;/U&gt;. I had to call the '.grouped()' function again to see the actual values. (JSON.stringify just DROPPED the grouped() result but that didn't mean it wasn't there)&lt;BR /&gt;A LOT of headscratches on this one.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Dec 2025 15:51:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Color-Formatting-for-Groups/m-p/4894436#M64038</guid>
      <dc:creator>matthias_vc</dc:creator>
      <dc:date>2025-12-05T15:51:03Z</dc:date>
    </item>
  </channel>
</rss>

