Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a line chart with Year and week as the dimensions. I have an expression for the color of the lines:
If(Year = Year(Today()), RGB(133,33,33),
If(Year = Year(Today()-365), RGB(216,103,103),
If(Year = Year(Today()-(365 * 2)), RGB(234,172,172)
)))
but I can't get a legend to show. Is it possible to show?
Thanks!
You can't have a legend if you're using 'Colour by Expression'
You can move the logic that identifies the difference between a date and todays date back to the load script, then colour by dimension.
Something like below will apply to all the dates within your data model. The output you're interested in is 'Year_Index'
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;
If you want specific colours you can define those as a master dimension, before the colour by dimension step.
You can't have a legend if you're using 'Colour by Expression'
You can move the logic that identifies the difference between a date and todays date back to the load script, then colour by dimension.
Something like below will apply to all the dates within your data model. The output you're interested in is 'Year_Index'
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;
If you want specific colours you can define those as a master dimension, before the colour by dimension step.