<?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: Color by Dimension is unexpectedly changing my bar chart in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/Color-by-Dimension-is-unexpectedly-changing-my-bar-chart/m-p/1608723#M11072</link>
    <description>&lt;P&gt;So I finally found a solution to this, but I don't really understand why. For the record, this behavior also occurs if you are trying to Color by Expression.&lt;/P&gt;&lt;P&gt;It seems that you have to somehow reference the Dimension that you are coloring by somewhere in the expression outside of the TOTAL qualifier. I was able to get it to work with this:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;=if(Not IsNull(STUDENT.YEAR), count({$} [Score]) / count({$} TOTAL&amp;lt;Year&amp;gt; [Score]))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;You don't have to use Not IsNull, but that is what I figured would be an easy way to do it.&lt;/P&gt;</description>
    <pubDate>Thu, 01 Aug 2019 23:34:30 GMT</pubDate>
    <dc:creator>dselgo_eidex</dc:creator>
    <dc:date>2019-08-01T23:34:30Z</dc:date>
    <item>
      <title>Color by Dimension is unexpectedly changing my bar chart</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Color-by-Dimension-is-unexpectedly-changing-my-bar-chart/m-p/1579083#M10514</link>
      <description>&lt;P&gt;Hello, I am currently working on a bar chart that will show the percent of students who achieved certain scores from year to year:&lt;BR /&gt;&lt;BR /&gt;Dimensions: [Score], [Year]&lt;/P&gt;&lt;P&gt;Measures: =count({$} [Score]) / count({$} TOTAL&amp;lt;Year&amp;gt; [Score])&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="barchart_color_auto.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/11866iBFEF088C66A4AA6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="barchart_color_auto.PNG" alt="barchart_color_auto.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Above is the expected view of the bar chart. But, when I change the chart to instead Color by Dimension, I get this:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="barchart_color_byDimension.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/11867i4220CCEB5758AA97/image-size/large?v=v2&amp;amp;px=999" role="button" title="barchart_color_byDimension.PNG" alt="barchart_color_byDimension.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I typically set all of my charts to color by dimension, but this chart is the only one behaving this way. The reason I am posting this question in this forum is because I am using the qVis API to generate these charts in my web app.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "qLibraryId": "",
    "qDef": {
        "qGrouping": "N",
        "qFieldDefs": ["Score"],
        "qFieldLabels": ["Score"],
        "qSortCriterias": [
            {
                "qSortByState": 0,
                "qSortByFrequency": 0,
                "qSortByNumeric": 0,
                "qSortByAscii": 1,
                "qSortByLoadOrder": 1,
                "qSortByExpression": 1,
                "qExpression": {
                    "qv": "Score"
                },
                "qSortByGreyness": 0
            }
        ],
        "qNumberPresentations": [],
        "qReverseSort": false,
        "qActiveField": 0,
        "qLabelExpression": "",
        "autoSort": false,
        "cId": "rpbxTj",
        "othersLabel": "Others",
        "textAlign": {
            "auto": true,
            "align": "left"
        },
        "representation": {
            "type": "text",
            "urlLabel": ""
        }
    },
    "qNullSuppression": true,
    "qIncludeElemValue": false,
    "qOtherTotalSpec": {
        "qOtherMode": "OTHER_OFF",
        "qOtherCounted": {
            "qv": "10"
        },
        "qOtherLimit": {
            "qv": "0"
        },
        "qOtherLimitMode": "OTHER_GE_LIMIT",
        "qSuppressOther": false,
        "qForceBadValueKeeping": true,
        "qApplyEvenWhenPossiblyWrongResult": true,
        "qGlobalOtherGrouping": false,
        "qOtherCollapseInnerDimensions": false,
        "qOtherSortMode": "OTHER_SORT_DESCENDING",
        "qTotalMode": "TOTAL_OFF",
        "qReferencedExpression": {
            "qv": ""
        }
    },
    "qShowTotal": false,
    "qShowAll": false,
    "qOtherLabel": {
        "qv": "Others"
    },
    "qTotalLabel": {
        "qv": "Totals"
    },
    "qCalcCond": {
        "qv": ""
    },
    "qAttributeExpressions": [],
    "qAttributeDimensions": [
        {
            "qDef": "Score",
            "qLibraryId": "",
            "qSortBy": {
                "qSortByState": 0,
                "qSortByFrequency": 0,
                "qSortByNumeric": 0,
                "qSortByAscii": 1,
                "qSortByLoadOrder": 1,
                "qSortByExpression": 1,
                "qExpression": {
                    "qv": "Score"
                },
                "qSortByGreyness": 0
            },
            "qAttribute": true,
            "id": "colorByAlternative",
            "label": "Score"
        }
    ],
    "qCalcCondition": {
        "qCond": {
            "qv": ""
        },
        "qMsg": {
            "qv": ""
        }
    },
    "othersLabel": "Others"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "qLibraryId": "",
    "qDef": {
        "qGrouping": "N",
        "qFieldDefs": ["Year"],
        "qFieldLabels": ["Year"],
        "qSortCriterias": [
            {
                "qSortByState": 0,
                "qSortByFrequency": 0,
                "qSortByNumeric": 1,
                "qSortByAscii": 1,
                "qSortByLoadOrder": 1,
                "qSortByExpression": 0,
                "qExpression": {
                    "qv": ""
                },
                "qSortByGreyness": 0
            }
        ],
        "qNumberPresentations": [],
        "qReverseSort": false,
        "qActiveField": 0,
        "qLabelExpression": "",
        "autoSort": true,
        "cId": "nvPJMJ",
        "othersLabel": "Others"
    },
    "qNullSuppression": true,
    "qIncludeElemValue": false,
    "qOtherTotalSpec": {
        "qOtherMode": "OTHER_OFF",
        "qOtherCounted": {
            "qv": "10"
        },
        "qOtherLimit": {
            "qv": "0"
        },
        "qOtherLimitMode": "OTHER_GE_LIMIT",
        "qSuppressOther": false,
        "qForceBadValueKeeping": true,
        "qApplyEvenWhenPossiblyWrongResult": true,
        "qGlobalOtherGrouping": false,
        "qOtherCollapseInnerDimensions": false,
        "qOtherSortMode": "OTHER_SORT_DESCENDING",
        "qTotalMode": "TOTAL_OFF",
        "qReferencedExpression": {
            "qv": ""
        }
    },
    "qShowTotal": false,
    "qShowAll": false,
    "qOtherLabel": {
        "qv": "Others"
    },
    "qTotalLabel": {
        "qv": "Totals"
    },
    "qCalcCond": {
        "qv": ""
    },
    "qAttributeExpressions": [],
    "qAttributeDimensions": [
        {
            "qDef": "Year",
            "qLibraryId": "",
            "qSortBy": {
                "qSortByState": 0,
                "qSortByFrequency": 0,
                "qSortByNumeric": 1,
                "qSortByAscii": 1,
                "qSortByLoadOrder": 1,
                "qSortByExpression": 0,
                "qExpression": {
                    "qv": ""
                },
                "qSortByGreyness": 0
            },
            "qAttribute": true,
            "id": "colorByAlternative",
            "label": "Year"
        }
    ],
    "qCalcCondition": {
        "qCond": {
            "qv": ""
        },
        "qMsg": {
            "qv": ""
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems to me that the "qAttributeDimensions" is a part of the problem. I checked the properties in the two charts above and found that in the first (correct) image, "qAttributeDimensions" is []. In the second image, "qAttributeDimensions" has a value for the Year field. I expected this property change, but I don't understand why it has an affect on the chart like this.&lt;/P&gt;&lt;P&gt;Here is a basic idea of what the data model looks like:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="barchart_color_dataModel.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/11873i6CCAF7FDE5A7F381/image-size/large?v=v2&amp;amp;px=999" role="button" title="barchart_color_dataModel.PNG" alt="barchart_color_dataModel.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I would post an example, but in all honesty I tried creating one and could not replicate this same behavior with fake data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Before anyone suggests this, I have set my barchart "color" property to "auto": true, but I use applyPatches() in my app and this sets the "qDimensionAttributes" of my chart.&lt;/P&gt;&lt;P&gt;Any help would be appreciated!&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 05:52:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Color-by-Dimension-is-unexpectedly-changing-my-bar-chart/m-p/1579083#M10514</guid>
      <dc:creator>dselgo_eidex</dc:creator>
      <dc:date>2024-11-16T05:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: Color by Dimension is unexpectedly changing my bar chart</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Color-by-Dimension-is-unexpectedly-changing-my-bar-chart/m-p/1608723#M11072</link>
      <description>&lt;P&gt;So I finally found a solution to this, but I don't really understand why. For the record, this behavior also occurs if you are trying to Color by Expression.&lt;/P&gt;&lt;P&gt;It seems that you have to somehow reference the Dimension that you are coloring by somewhere in the expression outside of the TOTAL qualifier. I was able to get it to work with this:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;=if(Not IsNull(STUDENT.YEAR), count({$} [Score]) / count({$} TOTAL&amp;lt;Year&amp;gt; [Score]))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;You don't have to use Not IsNull, but that is what I figured would be an easy way to do it.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 23:34:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Color-by-Dimension-is-unexpectedly-changing-my-bar-chart/m-p/1608723#M11072</guid>
      <dc:creator>dselgo_eidex</dc:creator>
      <dc:date>2019-08-01T23:34:30Z</dc:date>
    </item>
  </channel>
</rss>

