Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All ,
My Qliksense model got SET vMaxUWMonth=Max([UW_MONTH_KEY]); which is the maximum month. How to show the name of the Month as 'April 2019;
Current Month - UW_ MONTH_KEY = 201910
Current Month Name - 'April 2019;
Please see below ;
Sample model attached.
Thanks a lot . It worked 100%.
If your source data contains UW_MONTH_KEY and UW_MONTH_NAME, then I would load the data using dual(UW_MONTH_NAME, UW_MONTH_KEY) as [UW Month]. In this manner, you could have relationships based on UW_MONTH_KEY, but the "UW Month" field would be used on the dashboard especially as the Axis on any Charts. It will sort Numerically but display the corresponding text.
See https://help.qlik.com/en-US/sense/latest/Subsystems/Hub/Content/Sense_Hub/Scripting/FormattingFuncti...
If you don't have a UW_MONTH_NAME field, you could derive this using MonthName( Date#( UW_MONTH_KEY, 'YYYYMM'), -6)
Also consider deriving a Date Hierarchy using the more advanced approach documented at https://help.qlik.com/en-US/sense/February2019/Subsystems/Hub/Content/Sense_Hub/Scripting/derived-fi...
// See also https://help.qlik.com/en-US/sense/latest/Subsystems/Hub/Content/Sense_Hub/Scripting/FormattingFunctions/Dual.htm
[Dates]:
LOAD *,
dual(UW_MONTH_NAME, UW_MONTH_KEY) as [UW Month],
dual(MonthName([Financial MonthEnd]), UW_MONTH_KEY) as [Financial Month]
;
// these derived calculations use the results from below
LOAD *,
rand() as [Amount], // an arbitrary measure for a sample chart
MonthEnd(Date#(UW_MONTH_KEY,'YYYYMM'),-6) as [Financial MonthEnd]
;
// this would be read from your database
LOAD * INLINE [
UW_MONTH_KEY, UW_MONTH_NAME
201901, Jul 2018
201902, Aug 2018
201903, Sep 2018
201904, Oct 2018
201905, Nov 2018
201906, Dec 2018
201907, Jan 2019
201908, Feb 2019
201909, Mar 2019
201910, Apr 2019
201911, May 2019
201912, Jun 2019
];
// See also https://help.qlik.com/en-US/sense/latest/Subsystems/Hub/Content/Sense_Hub/Scripting/derived-fields.htm
[Financial Calendar]:
DECLARE FIELD DEFINITION TAGGED '$date'
Parameters
first_month_of_year = 6
Fields
Year($1) As Year Tagged ('$numeric'),
Month($1) as Month Tagged ('$numeric'),
Date($1) as Date Tagged ('$date'),
Week($1) as Week Tagged ('$numeric'),
Weekday($1) as Weekday Tagged ('$numeric'),
DayNumberOfYear($1, first_month_of_year) as DayNumberOfYear Tagged ('$numeric')
Groups
Year, Week, Weekday type drilldown as YearWeekDayName,
Year, Month, Date type collection as YearMonthDate;
DERIVE FIELDS FROM FIELDS [Financial MonthEnd] USING [Financial Calendar];