<?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: Line Chart Legend in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Line-Chart-Legend/m-p/2488543#M101692</link>
    <description>&lt;P&gt;You can't have a legend if you're using 'Colour by Expression'&lt;BR /&gt;&lt;BR /&gt;You can move the logic that identifies the difference between a date and todays date back to the load script, then colour by dimension.&lt;/P&gt;
&lt;P&gt;Something like below will apply to all the dates within your data model. The output you're interested in is 'Year_Index'&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Let vDataCurrency = Today();

SET MonthDiff = ((year(Monthstart('$(vDataCurrency)'))*12)+month(Monthstart('$(vDataCurrency)'))) - (((year($1)*12)+month($1)));
SET WeekDiff = ((year(weekstart('$(vDataCurrency)'))*52)+week(weekstart('$(vDataCurrency)'))) - (((year($1)*52)+week($1)));
SET QuarterDiff = (((year(monthstart('$(vDataCurrency)'))))*4+ceil(month('$(vDataCurrency)')/3))- (((year(monthstart($1))))*4+ceil(month($1)/3));
SET YearDiff = (((year(monthstart('$(vDataCurrency)')))) - ((year(monthstart($1)))));
SET FinancialDiff = year(yearstart('$(vDataCurrency)', 0, 7))-(year(yearstart(($1), 0, 7)));

[autoCalendar]:
DECLARE FIELD DEFINITION Tagged ('$date')
FIELDS
    $(WeekDiff($1)) as Week_Index
	,$(MonthDiff($1)) as Month_Index
    ,$(QuarterDiff($1)) as Quarter_Index  
    ,$(YearDiff($1)) as Year_Index
    ,$(FinancialDiff($1)) as Financial_Year_Index
    ;
DERIVE FIELDS FROM EXPLICIT TAGS ('$date','$timestamp') USING autoCalendar;&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;If you want specific colours you can define those as a master dimension, before the colour by dimension step.&lt;/P&gt;</description>
    <pubDate>Tue, 22 Oct 2024 23:38:59 GMT</pubDate>
    <dc:creator>Tomm</dc:creator>
    <dc:date>2024-10-22T23:38:59Z</dc:date>
    <item>
      <title>Line Chart Legend</title>
      <link>https://community.qlik.com/t5/App-Development/Line-Chart-Legend/m-p/2488537#M101690</link>
      <description>&lt;P&gt;I have a line chart with Year and week as the dimensions. I have an expression&amp;nbsp; for the color of the lines:&lt;/P&gt;
&lt;P&gt;If(Year = Year(Today()), RGB(133,33,33),&lt;BR /&gt;If(Year = Year(Today()-365), RGB(216,103,103),&lt;BR /&gt;If(Year = Year(Today()-(365 * 2)), RGB(234,172,172)&lt;BR /&gt;)))&lt;/P&gt;
&lt;P&gt;but I can't get a legend to show. Is it possible to show?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mikecrengland_0-1729632223782.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/173287iD6C4DA85D71191CB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mikecrengland_0-1729632223782.png" alt="mikecrengland_0-1729632223782.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 21:25:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Line-Chart-Legend/m-p/2488537#M101690</guid>
      <dc:creator>mikecrengland</dc:creator>
      <dc:date>2024-10-22T21:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: Line Chart Legend</title>
      <link>https://community.qlik.com/t5/App-Development/Line-Chart-Legend/m-p/2488543#M101692</link>
      <description>&lt;P&gt;You can't have a legend if you're using 'Colour by Expression'&lt;BR /&gt;&lt;BR /&gt;You can move the logic that identifies the difference between a date and todays date back to the load script, then colour by dimension.&lt;/P&gt;
&lt;P&gt;Something like below will apply to all the dates within your data model. The output you're interested in is 'Year_Index'&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Let vDataCurrency = Today();

SET MonthDiff = ((year(Monthstart('$(vDataCurrency)'))*12)+month(Monthstart('$(vDataCurrency)'))) - (((year($1)*12)+month($1)));
SET WeekDiff = ((year(weekstart('$(vDataCurrency)'))*52)+week(weekstart('$(vDataCurrency)'))) - (((year($1)*52)+week($1)));
SET QuarterDiff = (((year(monthstart('$(vDataCurrency)'))))*4+ceil(month('$(vDataCurrency)')/3))- (((year(monthstart($1))))*4+ceil(month($1)/3));
SET YearDiff = (((year(monthstart('$(vDataCurrency)')))) - ((year(monthstart($1)))));
SET FinancialDiff = year(yearstart('$(vDataCurrency)', 0, 7))-(year(yearstart(($1), 0, 7)));

[autoCalendar]:
DECLARE FIELD DEFINITION Tagged ('$date')
FIELDS
    $(WeekDiff($1)) as Week_Index
	,$(MonthDiff($1)) as Month_Index
    ,$(QuarterDiff($1)) as Quarter_Index  
    ,$(YearDiff($1)) as Year_Index
    ,$(FinancialDiff($1)) as Financial_Year_Index
    ;
DERIVE FIELDS FROM EXPLICIT TAGS ('$date','$timestamp') USING autoCalendar;&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;If you want specific colours you can define those as a master dimension, before the colour by dimension step.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 23:38:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Line-Chart-Legend/m-p/2488543#M101692</guid>
      <dc:creator>Tomm</dc:creator>
      <dc:date>2024-10-22T23:38:59Z</dc:date>
    </item>
  </channel>
</rss>

