Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
l_boccasso
Partner - Contributor
Partner - Contributor

Complex Time dimension

Hello,

I have to build a chart like the one picture.

grafico.jpg

Time dimension (on x axis) is dynamic and it has 4 elements YTD, Last YTD, Full Last Year, Full two Last Year.

Users can change month and year of analysis.

How can I build this dimension? Calculated dimension?

Thanks.

4 Replies
ElizaF
Creator II
Creator II

Hi Luca,

The solution can be:

1. To use Alternate States (vers. 11+) in the chart - to avoid any change of the data according the user selection.

2. For calculate value in the chart use Set Analysis function:

Current Year -  Sum( {$ <CalYear={ $(=max(CalYear)) }>} SalesAmount)

LYTD -  Sum( {$ <CalYear={ $(=max(CalYear)) }>} SalesAmount*_FLAGLYTD)

Full last Year -  Sum( {$ <CalYear={$(=max(CalYear)-1)}>} SalesAmount)

Full two Year  -  Sum( {$ <CalYear={$(=max(CalYear)-2)}>} SalesAmount)

_FLAGLYTD =inyeartodate (DataSales, Today(), -1 ) - calculated in scrip.


Hope help you!


    

krishna_2644
Specialist III
Specialist III

I guess its possible.Let me give a try ,if u can provide some sample data.

jpapador
Partner - Specialist
Partner - Specialist

assuming you had a YTD flag in the script you could do something like below:

Dimension:

Calculated: =Valuelist('YTD 2014', 'LYTD 2015', '(full)2014', '(full)2013')

Expression: 1 long IF statement

If(Valuelist('YTD 2015', 'LYTD 2014', '(full)2014', '(full)2013') = 'YTD 2015',

Sum({$<Year={$(=Max(Year))}, YTDFlag={1}>} Sales),

If(Valuelist('YTD 2015', 'LYTD 2014', '(full)2014', '(full)2013') = 'LYTD 2014',

Sum({$<Year={$(=Max(Year)-1)}, YTDFlag={1}>} Sales),

if(Valuelist('YTD 2015', 'LYTD 2014', '(full)2014', '(full)2013') = '(full)2014',

Sum({$<Year={$(=Max(Year)-1)}>} Sales),

f(Valuelist('YTD 2015', 'LYTD 2014', '(full)2014', '(full)2013') = '(full)2013',

Sum({$<Year={$(=Max(Year)-2)}>} Sales)))))

They would still be able to make month and year selections.

l_boccasso
Partner - Contributor
Partner - Contributor
Author

thank you jpapador, you found the solution!